Fix player jitter on moving platforms
This commit is contained in:
22
Assets/Content/Scripts/ParentSimuator.cs
Normal file
22
Assets/Content/Scripts/ParentSimuator.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
|
||||
[DefaultExecutionOrder(1)]
|
||||
public class ParentSimuator : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Transform _target;
|
||||
[SerializeField] Vector3 _targetPosition;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_targetPosition = _target.InverseTransformPoint(transform.position);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
Vector3 targetPosition = _target.TransformPoint(_targetPosition);
|
||||
|
||||
transform.position = targetPosition;
|
||||
|
||||
_targetPosition = _target.InverseTransformPoint(transform.position);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user