When spawning objects at random locations I'm getting objects that are overlapping each other. Is there a way for me to tell when two bodies intersect and know the direction I need to move them so that they no longer intersect?
- (void) avoidCollision:(b2Body *) body {
b2ContactEdge* edge = body->GetContactList();
while (edge) {
b2Contact* contact = edge->contact;
if (contact->IsTouching()) {
NSLog(@"body is touching");
// do something here to avoid the contact...
}
edge = edge->next;
}
}
- (void) avoidCollision:(b2Body *) body {
b2ContactEdge* edge = body->GetContactList();
while (edge) {
b2Contact* contact = edge->contact;
if (contact->IsTouching()) {
NSLog(@"body is touching");
// do something here to avoid the contact...
}
edge = edge->next;
}
}