|
|
|
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
public class FollowPositionRig : MonoBehaviour |
|
|
|
namespace NaughtyAttributes.Rigs |
|
|
|
public Transform target => m_Target; |
|
|
|
public class FollowPositionRig : MonoBehaviour |
|
|
|
{ |
|
|
|
public Transform target => m_Target; |
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
protected Transform m_Target; |
|
|
|
public float Dampen = 1.0f; |
|
|
|
public float MaximumVelocity = 1.0f; |
|
|
|
[SerializeField] |
|
|
|
protected Transform m_Target; |
|
|
|
public float Dampen = 1.0f; |
|
|
|
public float MaximumVelocity = 1.0f; |
|
|
|
void Update() |
|
|
|
{ |
|
|
|
if(m_Target != null) |
|
|
|
{ |
|
|
|
var transform = gameObject.transform; |
|
|
|
var delta = m_Target.position - transform.position; |
|
|
|
var speed = Time.deltaTime * Mathf.Min((Dampen * delta.magnitude), MaximumVelocity); |
|
|
|
gameObject.transform.position += delta.normalized * speed; |
|
|
|
} |
|
|
|
} |
|
|
|
void Update() |
|
|
|
{ |
|
|
|
if(m_Target != null) |
|
|
|
public void SetTarget(Transform target) |
|
|
|
var transform = gameObject.transform; |
|
|
|
var delta = m_Target.position - transform.position; |
|
|
|
var speed = Time.deltaTime * Mathf.Min((Dampen * delta.magnitude), MaximumVelocity); |
|
|
|
gameObject.transform.position += delta.normalized * speed; |
|
|
|
m_Target = target; |
|
|
|
} |
|
|
|
public void SetTarget(Transform target) |
|
|
|
{ |
|
|
|
m_Target = target; |
|
|
|
|
|
|
|
} |