Unity中简单的摄像机视角跟随鼠标转动而转动
程序员文章站
2022-04-21 20:06:44
这里写自定义目录标题没有废话直接上代码,直接拖入摄像机里即可使用没有废话直接上代码,直接拖入摄像机里即可使用using System.Collections;using System.Collections.Generic;using UnityEngine;public class Camerafollow : MonoBehaviour{ public float moveSpeed; // Start is called before the first frame up...
这里写自定义目录标题
没有废话直接上代码,直接拖入摄像机里即可使用
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Camerafollow : MonoBehaviour
{
public float moveSpeed;
// Start is called before the first frame update
void Start()
{
moveSpeed = 60f; //移动速度
}
// Update is called once per frame
void Update()
{
Vector3 angle = Vector3.zero;
angle.x = transform.localEulerAngles.x - Input.GetAxis("Mouse Y") * moveSpeed * Time.deltaTime;
angle.y = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * moveSpeed * Time.deltaTime;
transform.localEulerAngles = angle;
}
}
本文地址:https://blog.csdn.net/weixin_44277869/article/details/108976233
上一篇: vc5tray.exe是什么进程
下一篇: crontab的默认执行路径问题