Hi everyone
Im using box2d in my game and i have a problem
I need to determinate collision between two objects but only if they are touched with one exact side. For instance bottom of one object collided with top of another object.
Could you give a pice of advice how can i do it?
box2d collision detection
(4 posts) (4 voices)-
Posted 1 year ago #
-
I can think of 2 ways. First is to get the contact points, and convert them to local coordinates of the item being hit, then check where it is. I've done this before, the only problem I had was multiple contacts and so on.
If I were to do it again, I'd probably just use a sensor on the side(s) of the object(s) I was interested in, and by definition you'll get the contact you want.Someone else might have a better idea..!
Posted 1 year ago # -
You probably already found an answer for this but I thought I'd answer it in case someone else needs it.
Create your bodies using a fixture that you can identify in the location you want the collision to happen at.
In your collision filters, filter for the collision between those unique fixtures instead of just any fixtures.
Posted 1 year ago # -
hi there, I don't want to start a new thread, my guestion is just:
for collision detection - when 2 bodies hit each other, i should make a function like
-(void) crash{ if (abs( getposition1 - getposition 2......... < 5.. { play sound } }or is there any better way using collision manager or how it is named?
i just need play a sound when body 1 crash to body 2, and know this in my application, that it happend..
what would you recommend to me?
and i think, this crash function should be called in TICK void, right?
Posted 11 months ago #
Reply
You must log in to post.