- Home /
How do I make c# script to have a player not fall through a platform?
I want to have a basic platform and when the player (sphere) collides with the platform they do not fall through. I got that to work but when the player steps off of the platform they do not fall. How would i do that? (in c#)
If you have tried a rigidbody, and he falls through the platform. Either the starting position is right inside of the hit box. Or you do not have a collider on the ground and / or the player.
$$anonymous$$ake sure the colliders are not set to IsTrigger (see in Box / sphere colliders).
You must make sure to create a plane at the bottom for the player to fall on.
Also, if you have a sphere with a rigidbody it will roll around. So you must lock rotation on X, Y and Z axis in the rigidbody handler under "Constraints"
the sphere and the platform are both checked IsTrigger but the material (in sphere collider) says none. Is that a problem?
Is there some place where i could download an example world/scene to look at it?
Answer by Mulldor · Jul 21, 2015 at 10:33 PM
Just add a rigidbody, and let it do the work.
Either that, or you read up a little bit on character controllers see:
https://www.youtube.com/watch?v=AEPI5rmg3XY for a good guide
Answer by Guandor · Jul 21, 2015 at 10:41 PM
Add rigidbody to the player and colliders to both player and the platform.
Answer by Vray · Jul 22, 2015 at 10:01 AM
An alternative I am working with is navmeshAgent Its a simple solution to a complex problem. If your looking for a dirty alternative for collision.