- Home /
Rigidbody detect collision with the side of an object
I'm creating a 2d platformer and I want to interact with the world in a very contextual way, In order to gain context on where the player is I want to be able to detect collision with specific sides of my platforms.
I basically want to know the best practice method of detecting collision with specific sides of an object.
I am NOT using a CharacterController so the CollisionFlags does not apply, I'm basically wanting to recreate the collision flags with my Rigidbody character
Answer by kolban · Apr 16, 2012 at 01:44 PM
I believe one possible answer would be to create multiple child empty objects as children of your platform. For each of those empties, give each one a collision box and size appropriately. By detecting collisions with your own manually created collision boxes you will now have a much finer grained control over detection of where an interaction occurred.
Thanks for the reply, this crossed my $$anonymous$$d and I wondered if there would be any performance issues with having four of more empty colliders on each platform? I think this may be the best option though, thanks.
Have a look at this URL from Unity's own documentation. About 1/2 way down the page there appears to be an example of the area we are chatting about.
http://unity3d.com/support/documentation/Components/class-BoxCollider.html
Your answer
Follow this Question
Related Questions
2D how to jump just from the top of the box 0 Answers
[2Dplatformer][Problem] When the player closes to the enemy, the enemy pass through the colliders 0 Answers
2D game with depth, basics? 2 Answers
controller.collisionFlags & CollisionFlags.Sides Not working 2 Answers
Making Sprite Disappear on Trigger 2 Answers