19 lines
624 B
C#
19 lines
624 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class Mover : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] private float speed;
|
||
|
[SerializeField] private GameObject target;
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void FixedUpdate()
|
||
|
{
|
||
|
//transform.LookAt(player.transform);
|
||
|
Quaternion targetRotation = Quaternion.LookRotation(target.transform.position - transform.position);
|
||
|
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, 1 * Time.deltaTime);
|
||
|
transform.position += transform.forward * speed * Time.deltaTime;
|
||
|
}
|
||
|
}
|