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

27 lines
728 B
C#

using Ktyl.Util;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Mover : MonoBehaviour
{
[SerializeField] private float speed;
[SerializeField] private GameObject target;
[SerializeField] private SerialFloat objectTimeScale;
private void OnEnable()
{
float dt = Time.fixedDeltaTime;
Quaternion targetRotation = Quaternion.LookRotation(target.transform.position - transform.position);
transform.rotation = targetRotation;
}
// Update is called once per frame
void FixedUpdate()
{
float dt = Time.fixedDeltaTime;
transform.position += transform.forward * speed * dt * objectTimeScale;
}
}