25 lines
643 B
C#
25 lines
643 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Mover : MonoBehaviour
|
|
{
|
|
[SerializeField] private float speed;
|
|
[SerializeField] private GameObject target;
|
|
|
|
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;
|
|
}
|
|
}
|