Compound players with multiple bodies/fixtures?
Posted: Tue Aug 21, 2012 11:49 am
Hi guys.. I'm studying collisions with physics engine.. I have created a "player" who I can move
left, right and jump, the player is a simple square body. Now, I want to be able to know what part
of my player is colliding when a collision is detected.. so, if the bottom part of my player is colliding
this means that he is on top of something.. I want it to jump only if is on top of something..
There are two ways,
1.- I can check the direction of the colision, geting the edges where the colision happen. So if a collision happens
on bottom part I know that my player is on top of something
2.- I can create a compound body, with multiple fixtures.. for example, one for foot, one for head, and one for body..
If i detect a collision on foot I know that I'm on top of something..
I have no idea of how to do any of this things, I guess collision object can give-me 1..For 2.. I know how to create multiple fixtures,
the problem is how to tie they together in an elegant way.
Any idea?
I will post the code I have .... just let me get to another computer where it is ...
Thanks!
left, right and jump, the player is a simple square body. Now, I want to be able to know what part
of my player is colliding when a collision is detected.. so, if the bottom part of my player is colliding
this means that he is on top of something.. I want it to jump only if is on top of something..
There are two ways,
1.- I can check the direction of the colision, geting the edges where the colision happen. So if a collision happens
on bottom part I know that my player is on top of something
2.- I can create a compound body, with multiple fixtures.. for example, one for foot, one for head, and one for body..
If i detect a collision on foot I know that I'm on top of something..
I have no idea of how to do any of this things, I guess collision object can give-me 1..For 2.. I know how to create multiple fixtures,
the problem is how to tie they together in an elegant way.
Any idea?
I will post the code I have .... just let me get to another computer where it is ...
Thanks!