okay thanks for reading.
below is my code for the begin contact function of the contactListener class.
have a read of that then these are my questions:
do i have to check if the contact is touching ?
if i dont do this will i get contacts that are just aabb overlaps ?
notice how I check if the bullet is either A or B
so I have to code everything twice.
is that how this should be coded ? is there a better way to do this so I dont have to double up code ?
thanks
below is my code for the begin contact function of the contactListener class.
have a read of that then these are my questions:
do i have to check if the contact is touching ?
if i dont do this will i get contacts that are just aabb overlaps ?
notice how I check if the bullet is either A or B
so I have to code everything twice.
is that how this should be coded ? is there a better way to do this so I dont have to double up code ?
thanks
Code:
public virtual function BeginContact(contact:b2Contact):void {
var A=contact.GetFixtureA().GetUserData();
var B=contact.GetFixtureB().GetUserData();
if (contact.IsTouching()) {
if (A is bullet) {
if (B is player) {
trace("trace the bullet hit the player")
}
}
if (B is bullet) {
if (A is player) {
trace("trace the bullet hit the player")
}
}
}
}
var A=contact.GetFixtureA().GetUserData();
var B=contact.GetFixtureB().GetUserData();
if (contact.IsTouching()) {
if (A is bullet) {
if (B is player) {
trace("trace the bullet hit the player")
}
}
if (B is bullet) {
if (A is player) {
trace("trace the bullet hit the player")
}
}
}
}