赞
踩
这次实现类似绝地求生
这个游戏中的 第三人称视角
的相机跟随
直接把相机挂载到角色模型作为子级
调整好角度与位置,初步实现第三人称视角
PlayerController.cs
挂载到Player
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public float rotationSpeed = 200f; private float mouseX; private float mouseY; void Start() { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } void Update() { mouseX = Input.GetAxis("Mouse X") * rotationSpeed * Time.deltaTime; transform.Rotate(new Vector3(0f, mouseX, 0f), Space.Self); mouseY -= Input.GetAxis("Mouse Y") * rotationSpeed * Time.deltaTime; mouseY = Mathf.Clamp(mouseY, -40f, 40f); Camera.main.transform.localEulerAngles = new Vector3(mouseY, 0, 0); } }
对不同的需求有不同的相机跟随的实现方法,灵活运用才是正解
Enjoy~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。