Making stunts in Bike

Hmm... I guess you could use the body type, but I think it would be very confusing. For example, I think you have at least three dynamic bodies in your game (the bike body and the two wheels), so if you only check the body type you don't know which one of these is touching the ground. But maybe that's ok. As long as you keep track of the total number of contacts with the ground, then when it is zero you know that no part of the bike is touching the ground.
Thanks for your reply. Let me try and come with more questions.

Your explanation in the site is very much clear and useful. Kindly bare me if my question is stupid and not clear.
public virtual function BeginContact(contact:b2Contact):void
{
if((contact.GetFixtureA().GetBody().GetUserData().name=="leftWheel" || contact.GetFixtureA().GetBody().GetUserData().name=="rightWheel") && contact.GetFixtureB().GetBody().GetUserData().name=="path")
{
startContact()
}
}


public virtual function EndContact(contact:b2Contact):void
{

if((contact.GetFixtureA().GetBody().GetUserData().name=="leftWheel" || contact.GetFixtureA().GetBody().GetUserData().name=="rightWheel") && contact.GetFixtureB().GetBody().GetUserData().name=="path")
{
endContact()
}

}

function startContact ()
{
contactCount++
trace("start="+contactCount)
}

function endContact ()
{
contactCount--
trace("end="+contactCount)
}

is i'm doing it correct?

If i code like this, the count is setting to zero or one or two not more then that.

And if the bike is in contact also, the count is not getting increase more than 2. Help me to do it correctly?
Can i use ComplexHitTest for this contact checking?
There is no 'correct' value for the number of contacts, it depends on what's happening in your scene.

In your code, fixtureA could also be the "path", but you are only checking if fixtureB is the path. So you need to check the opposite case as well. Now you have:

( a == leftWheel || a == rightWheel ) && b == path

so you just need to make it:

( ( a == leftWheel || a == rightWheel ) && b == path ) ||
( b == leftWheel || b == rightWheel ) && a == path ) )

If you don't care about which wheel it is, you could give both wheels the same name and make it simpler:

( a == wheel && b == path ) || ( b == wheel && a == path )
StartContact- while the contact start between the bike and floor

EndContact-At the end of the contact between the bike and floor.


In between gap what the count will be if the bike is stopped in the floor without any movement?


if the bike is in air, the count is zero otherwise if it is running in floor the count will be one or two

Can i check the condition by the using if the count is zero to do the stunts?
Yes, that's the idea 😉

Original thread: https://box2d.org/forum/viewtopic.php?t=7998