关键功能:
- 摄影机跟随船体移动
- 船体在水面上晃动
- 摇杆控制方向
摄影机跟随对象的原理:
每一帧的开始的时候,都先去把这个摄影机移动到和对象相同的位置,然后收集跟随对象旋转的角度,然后将摄影家挪到对象的后面,在想上挪动一段距离,这个时候,摄影机就到了对象后面靠上,并一直跟着对象。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : MonoBehaviour
{
// 这个是我们跟随的对象
public new GameObject gameObject;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(gameObject == null)
{
return;
}
// 将摄影机的位置挪到我们跟随对象的位置
this.transform.position &#