3D CharacterController ride moving platforms in Unity?

I have a player controller script that I'm writing that uses the CharacterController component to move around and handle collisions. I've been able to implement basically every feature that I want except for moving platforms.

Some things to note:

-For testing purposes, the platform moves via the Update() function and does not have a Rigidbody component attached to it. I don't think that rigidbodies would make a difference in the first place, but I could be wrong.

-Currently, when my player stands on the platform, it kind of does what it's supposed to do, but it moves with a large amount of jitter. In other words, the player isn't able to depenetrate itself as fast as the platform moves, therefore causing the jitter.

Here's what I've tried:

My initial thought was to create a script on the moving platform that keeps track of its own velocity. Then, on the player's OnControllerColliderHit(...) function, I would get the platform's velocity and add it to the player's velocity. This caused the same jittery effect as before.

My next idea was to parent the player to the platform whenever the player collided with it. This solution also did not work because apparently CharacterControllers do NOT like it when they are a child of a moving object. The platform's transformations had little to no effect on the player, regardless of its speed. So once again, the jitteriness continued.

Just to test out possible solutions, I also tried combining the two previous fixes and still, the jitteriness lives among us.

Closing thoughts:

I'm beginning to think that it's not entirely possible, but I'm still holding out hope. I would also prefer to not to purchase an existing asset or switch to a Rigidbody component because neither would fit the style of my game.

Feel free to ask questions for more details and thank you in advance!

**EDIT** THIS QUESTION HAS BEEN MOVED TO GAMEDEV.STACKEXCHANGE.COM

Upvotes: 4

Views: 572

Answers (0)

Related Questions