问题:当转动摄像机的时候,角色也会转动。
增加以下代码:
private GameObject modle;//模型
void Awake() {
modle = playerHandle.GetComponent<ActorController>().model;//找到playerhandle里面的model赋值过来
}
void Update () {
Vector3 tempModelEuler = modle.transform.eulerAngles;
modle.transform.eulerAngles = tempModelEuler;
}
完成相机延迟跟随:
在主摄像机下建一个空对象(camerapos)然后反转父子关系,然后可以把主摄像机取出层级,使主摄像机的目的是追赶camerapos,把以前主摄像头的脚本挂给camerapos。再修改脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cameracontroller : MonoBehaviour {
public PlayerInput pi;//用来在update里面调整
public float horizontalSpeed = 100.0f;//可视化控制
public float verticalSpeed = 80.0f;
private GameObject playerHandle;
private GameObject cameraHandle;
private GameObject modle;//模型
private GameObject camera;
private float tempEule