- Home /
Rotation collision problem
Hey,
I'm make a 2.5d platformer and I'm created some rotating blocks see the block at the left, it's rotating around the z-axis. The problem is that when the block rotates, the box collider is going through the player, which causes it not to detect any collisions and then the player just falls through the object.
I'm slightly confused so if your player character is standing on the rotating block it just falls through?
or is it that the player cannot stand on the block at all because it is rotating?
I'm just gonna throw some random things at this as I don't know enough about whats going on in your game to say anything otherwise (hint hint, please post some code if you can :))
are you calculating physics in FixedUpdate?
check the box isn't a trigger
check the box has a collider
check the player has a rigidbody
check the player has a collider
no
no it's not like that
I said it had a box colider
I use a character controller, why would I need a rigid body?
the character controller also has a collider
I can stand on the block, just for a second.
sorry should've posted my code (to make it more clearly): https://www.dropbox.com/s/ew0izrkeq3p43xf/PlayerControlTwo.cs
I use OnControllerColliderHit for the vertically moving blocks
Answer by HappyMoo · Jan 21, 2014 at 03:01 PM
You most likely rotate something directly, that the physics engine doesn't expect you to rotate/move directly. Is that block kinematic?
See this video for details: http://www.youtube.com/watch?v=WFkbqdo2OI4
but how can I rotate it without doing it directly? I know I can add forces but that doesn't create a rotation with a constant speed
I agree with Happy$$anonymous$$oo, that's probably the solution. To rotate it indirectly at constant speed, you'd need to give the block a rigidbody, cancel gravity etc. on it, give it a very high mass relative to the player so the player doesn't affect its rotation, then just set the angularVelocity component of the rigidbody. And set the angularDrag to 0 so it keeps rotating at constant speed.
Set the rigidBody to kinematic, then you should be able to manipulate it by its Transform.