如何让相机后坐力上升?我不认为它在向上移动相机时使用协程。请帮忙.....
前后反冲是使用协程和 Lerp 像这样制作的,
```
Vector3 recoilBack = new Vector3(currentGun.retroActionForce, originPos.y, originPos.z); Vector3 retroActionRecoilBack = new Vector3(currentGun.retroActionFineSightForce, currentGun.FineSightOriginPos.y, currentGun.FineSightOriginPos.z);
if(!isfineSightMode) { currentGun.transform.localPosition = originPos; // start recoil back and forward while(currentGun.transform.localPosition.x <= currentGun.retroActionForce - 0.02f) { currentGun.transform.localPosition = Vector3.Lerp(currentGun.transform.localPosition, recoilBack, 0.4f); yield return null; } // back to place while(currentGun.transform.localPosition != originPos) { currentGun.transform.localPosition = Vector3.Lerp(currentGun.transform.localPosition, originPos, 0.1f); yield return null; } }
``` 上面的代码就是前后后坐的代码