- Home /
Rotate 2D hero based on small collisions. Is it possible?
I am new to Unity and this is just an idea. For what I know, unity collision detector is already built in Unity. In flash u could, based on what part of the hero was touching the ground, change it's rotation. Is there any chance that I can detect collisions for the hero as a whole and detect colisions, in only an area of this hero? For instance if his left foot was touching the ground and the right foot wasn't, he would rotate clockwise until both feets were touching terrain.
Thank you for any resposes
Answer by Kiloblargh · Jan 04, 2014 at 04:39 AM
Sure, it's possible. It's not anything that will be done automagically, you need to write code to make that happen. You can use Collision.contacts to get the normal and figure out what to do with that once you have it.
If "feet touching the ground" is what you are going for, there may be a shortcut- it's quite old, and I haven't messed with it in a while, but there is a Locomotion System package that you could use for a starting point and modify to work in 2D that will look much better than whatever you painstakingly hack together from contactpoint information.
Answer by superluigi · Jan 04, 2014 at 04:40 AM
if u put your own colliders, for example something like hitboxes, thenyes technically it should be possible. It could be something along the lines of "if left foot is touching something with this tag (terrain for example)", rotate around this axis".
Your answer
Follow this Question
Related Questions
RigidBody2D mouse going through Collider ,Rigidbody2D move with mouse 1 Answer
[2Dplatformer][Problem] When the player closes to the enemy, the enemy pass through the colliders 0 Answers
2D Detect collisions of a 2D block only on left/right (not top/bottom) 0 Answers
2D NPC should kill player on collision but does not. 1 Answer