x


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?

more ▼

asked Apr 13 '12 at 10:57 PM

chesterman gravatar image

chesterman
1 2 3 3

Is there a solution to this? I am experiencing the exact same issue.

Oct 08 '12 at 06:33 AM helios

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.

Oct 08 '12 at 07:16 AM shaderop
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1788
x666
x281
x202
x9

asked: Apr 13 '12 at 10:57 PM

Seen: 736 times

Last Updated: Oct 08 '12 at 07:16 AM