I'm trying to figure out how to detect when the contact between two bodies ends. I'm working on a car game something like alpine crawler and only when the rear wheel is touching the ground the car is able to accelerate.
This is my code for now but it doesn't work proper:
- (void) didBeginContact:(SKPhysicsContact *)contact
{
if (([contact.bodyB.node.name isEqualToString:@"rearWheel"] &&
[contact.bodyA.node.name isEqualToString:@"ground"])) {
isWheelOnGround = YES;
}
}
-(void) didEndContact:(SKPhysicsContact *)contact {
if (([contact.bodyB.node.name isEqualToString:@"rearWheel"] &&
[contact.bodyA.node.name isEqualToString:@"ground"])) {
isWheelOnGround = NO;
}
}