# Character shaking on moving platform (elevator)

Hey guys. Could someone help me? Whats the best way to move something like an elevator? I tried many ways but when my Character controller is standing on a rising platform he starts to shake (i’m guessing the elevator collider hits characters collider). Some say to parent the player from the elevetor onTriggerEnter but in my case it does nothing. I use standard Character controller for the player with applying vertical velocity for gravity in .Move() method I also use a SpereCast for ground checking, the elevator model only has a generated collider the one you get when importing an fbx model and right now I use Vector3.MoveTowards to move it up and down. Any help would be great thanks in advance.

Also, after some experimentation I found that if my vertical velocity (gravity) is equal to 0 when I’m grounded, character just falls through the elevator, but if Y velocity isn’t 0 (I have it at 6f) he doesn’t fall but the stuttering occurs…

I have the exact same problem, a shame there are no answers yet. Actually that’s true for most threads where it seems that that must have been solved before.

I ended up trying to get the difference between my elevator position and last frame position and add that to whatever enters the trigger- but it always returns 0.
That may be an hierarchical problem. Currently I don’t get why it would not calculate the difference right, but I’ll look at it again tomorrow.

## [TOMORROW EDIT]

ok, ive got half of it - I used an empty with Character Controller and had a Child with a capusle Collider and Rigidbody so i could bump into physic objects like boxes and stuff, that was part of the problem.
Now I moved the Collider and Rigidbody to the empty where the Character Controller is and in the Elevator Sticky Zone I used the difference position as a kind of velocity for everything that is on the elevator:

``````void Update(){
Vector3 dif = transform.position - previousPos;

foreach (GameObject o in objs) {
if(o.GetComponent<CharacterController>() != null) {
o.GetComponent<CharacterController>().Move(dif);
} else {
o.transform.position += dif;
}
}

previousPos = new Vector3(transform.position.x, transform.position.y, transform.position.z);
}
``````

objs is a list of gameObjects that gets filled and emptied on TriggerEnter and Exit
@gbagiryan

This works for left, right and up movement, the down movement is somewhat jerky again, I suspect bc of gravity or the antificial gravity in the character controller - with 0 gravity it works fine.
0 gravity messes up how you walk over slopes though, so you need something that zeroes it on the elevator.

private void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.tag == “Player”)
{
other.gameObject.transform.parent = this.gameObject.transform;
hasEntered = true;
}
}

``````private void OnTriggerExit2D(Collider2D other)
{
if (other.gameObject.tag == "Player")
{
other.gameObject.transform.parent = null;
hasEntered = false;
}
}
``````