I made an escalator and use a script to make my player (FPS) go up with the same speed as the escalator.
But when going up my player is dribbling a lot.
When changing the head-bob (on the FPSController) from on to off it’s a bit better but not what I really want.
Does someone have a solution for this.
My code:
public Transform target3b;
public float speed;
public GameObject Target3a;
bool moving = false;
void OnTriggerEnter(Collider col)
{
if (col.gameObject == Target3a)
{
moving = true;
}
}
void Update ()
{
if (moving)
{
float step = speed * Time.deltaTime;
transform.position = Vector3.MoveTowards (transform.position, target3b.position, step);
}
}
Is your escalator moving by means of keyframe animation? The problem with keyframed objects is that their Animator component is updated at a different rate than Update() or FixedUpdate() function. So if you try to match the position of the animated object in one of the update functions you may experience the jitter.
One way to deal with it is to use transform.SetParent to parent the character to the escalator step when the character is on it.