16 lines
399 B
C#
16 lines
399 B
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
namespace Plugins.RaycastPro.Demo.Scripts
|
||
|
|
{
|
||
|
|
public class FollowTarget : MonoBehaviour
|
||
|
|
{
|
||
|
|
[SerializeField] private Rigidbody _rigidbody;
|
||
|
|
public Transform target;
|
||
|
|
[SerializeField] private float speed;
|
||
|
|
void Update()
|
||
|
|
{
|
||
|
|
_rigidbody.linearVelocity = (target.position - transform.position).normalized * speed;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|