unity实现简单fps游戏鼠标功能
1.unity实现瞄准镜功能
实现原理
- 按下鼠标右键镜头拉近,再次按下镜头拉远(设置Camrea的FOV属性)
- 逐渐拉近(例如:60->20逐渐拉近)
- 设置缩放等级使每次点击的缩放效果不同
public class ScaleCamera : MonoBehaviour
{
private bool isFar=true;
private Camera cam;
private int[] zoomLength = {
60,40,20 };//设置缩放等级
private int length = 0;
// Start is called before the first frame update
void Start()
{