だから、私はビデオゲームのコーディングにかなり慣れていないので、フォロワースプライトをコーディングしようとしています. Pocket Mortys で Mortys が Ricks をフォローするのと同じようにしたいと思います。リックがたどる道の数歩遅れていること。私が試したすべてのことは、フォロワーがフォローしているスプライトの同じ側にとどまるか、回転しますが、3D フォロワーとして適切な場所に移動しません。私は何をすべきですか?よろしくお願いします!
編集:フォロワーにあるコードは次のとおりです。
UnityEngine の使用;
System.Collections を使用します。
public クラス FollowTheBoy : MonoBehaviour
{
private GameObject wayPoint;
private Vector3 wayPointPos;
private float speed = 1.5f;
void Start()
{
wayPoint = GameObject.Find("The Boy");
}
private Vector2 target;
void Update()
{
target = wayPoint.transform.position;
transform.position = Vector2.MoveTowards(transform.position, new Vector2(target.x - 1, target.y - 1), speed * Time.deltaTime);
}
}