- Home /
Character Controller vs moving platform
Hi all,
I have problem with using my player with characterController script taken from 2d Platformer Lerpz vs Moving platforms with rigidbody. The platform is moved by attached script in which I move the platform in FixedUpdate() function by these simple instructions:
myRigidbody.velocity = direction * stepHeight * constantSpeed;
Now, there is situation like this, the Player runs towards a moving block/platform and collision is'nt well detected.
P---><---B/P...
The Player just moves into this block! I am using on both sides functions like onCollisionEnter/Stay() but it still walks/jumps through those blocks/platforms. I have set box colliders and even tried with mesh colliders. This situation takes place only when both the player and the platform are going against each other. When they are going in the same direction, the collision works fine. My situation is like in 2d Platformer tutorial where the Lerpz can jump through opposite moving platform from the bottom of it. What am I doing wrong? Is there any healthy approach for controlling player and make him not to passthrough platforms from downside of the platform?
Is there a solution to this? I am experiencing the exact same issue.
Can you try lowering the relative speed of the player and the platform and then seen if that works? If it does work, then the easiest solution would be to use a bigger collider for your platforms.
This has to do with simulation quality and substeps, but I'm afraid I can't find a good summary of the subject. Basically, on one frame, your player and platform will be outside each other's colliders:
P--><--B
But on the next frame Unity will update their positions based on their velocities, but because they moving so fast, they will already have gone past each other on the next frame, and no collision will be triggered:
<--B P-->
That's my theory anyways. It could be that your problem is unrelated to all of this, and in that case, sorry.
Your answer
Follow this Question
Related Questions
Colliders Not Working 1 Answer
Navmeshagents, Character Controllers and Colliders 1 Answer
Small colliders go through objects 0 Answers
Is it new in Unity? Collider exception . . . 1 Answer
Multiple Colliders 1 Answer