You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
583 B
19 lines
583 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Follow : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Transform target;
|
|
// Start is called before the first frame update
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
Vector3 lookPos = target.position - transform.position;
|
|
Quaternion lookRot = Quaternion.LookRotation(lookPos, Vector3.up);
|
|
float eulerY = lookRot.eulerAngles.y;
|
|
Quaternion rotation = Quaternion.Euler(0, eulerY, 0);
|
|
transform.rotation = rotation;
|
|
}
|
|
}
|