2021-04-06 16:29:41 +02:00
|
|
|
using Ktyl.Util;
|
2021-03-25 20:00:13 +01:00
|
|
|
using System;
|
2021-03-18 13:34:08 +01:00
|
|
|
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-18 13:34:08 +01:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-03-18 13:34:08 +01:00
|
|
|
// 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;
|
2021-03-18 13:34:08 +01:00
|
|
|
}
|
|
|
|
}
|