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

27 lines
728 B
C#
Raw Normal View History

2021-04-06 16:29:41 +02:00
using Ktyl.Util;
2021-03-25 20:00:13 +01:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Mover : MonoBehaviour
{
[SerializeField] private float speed;
[SerializeField] private GameObject target;
2021-04-06 16:29:41 +02:00
[SerializeField] private SerialFloat objectTimeScale;
2021-03-25 20:00:13 +01:00
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()
{
2021-03-25 20:00:13 +01:00
float dt = Time.fixedDeltaTime;
2021-04-06 16:29:41 +02:00
transform.position += transform.forward * speed * dt * objectTimeScale;
}
}