revival/game/Assets/Scripts/Traps/Mover.cs

19 lines
624 B
C#
Raw Normal View History

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;
}
}