onCollision not being called
by Justin Mosiman · in Torque Game Builder · 08/02/2009 (10:47 pm) · 2 replies
I am probably not doing something really simple but this problem is killing me:
I have created two classes, t2dProjectile whose parent is t2dStaticSprite and the other class is t2dUnit, whose parent is t2dAnimatedSprite. The projectile is of type t2dProjectile and the unit is of type t2dUnit.
When the projectile is shot at the unit, the projectile's onCollision method is never called. On the projectile, I have called the following:
And the unit has the following properties:
In t2dProjectile I have created the following method:
I have debug rendering on in the scene and when the projectile intersects the unit's collision box they both turn green so I know for a fact that the projectile's collision box is intersecting the unit's collision box.
Is there anything that I'm doing wrong?
Thanks,
Justin
I have created two classes, t2dProjectile whose parent is t2dStaticSprite and the other class is t2dUnit, whose parent is t2dAnimatedSprite. The projectile is of type t2dProjectile and the unit is of type t2dUnit.
When the projectile is shot at the unit, the projectile's onCollision method is never called. On the projectile, I have called the following:
setCollisionActiveSend(true); setCollisionPhysicsSend(false);
And the unit has the following properties:
mAttackUnit->setCollisionActiveReceive(true); mAttackUnit->setCollisionPhysicsReceive(false);
In t2dProjectile I have created the following method:
void t2dProjectile::onCollision(t2dPhysics::cCollisionStatus* collisionStatus)
{
Con::errorf("Projectile collision");
}I have debug rendering on in the scene and when the projectile intersects the unit's collision box they both turn green so I know for a fact that the projectile's collision box is intersecting the unit's collision box.
Is there anything that I'm doing wrong?
Thanks,
Justin
#2
I have dug deeper into this and it looks like the collisions only happen when the objects are in camera view. When I am looking at where the collision takes place, onCollision is called. When I have the camera pointing somewhere else, it doesn't get called.
Edit: I removed some comments about what I thought it was, and after some more debugging that turned out to be wrong. Here is where I am at: It looks like the object that has collisionSend enabled only checks for collisions with other objects within the camera view. How can you override this?
Edit #2: I figured out where it is clipping objects that aren't within the view, t2dSceneContainer::findPotentialCollisions. It looks like I am either going to have to detect collisions with every object in the scene or write some custom code for my particular object that I am interested in having collisions.
08/05/2009 (8:56 pm)
Thanks Phillip, although it looks like this is a bigger problem than just enabling the onCollision callback. I'm not doing anything in script so enabling a script callback wouldn't do anything.I have dug deeper into this and it looks like the collisions only happen when the objects are in camera view. When I am looking at where the collision takes place, onCollision is called. When I have the camera pointing somewhere else, it doesn't get called.
Edit: I removed some comments about what I thought it was, and after some more debugging that turned out to be wrong. Here is where I am at: It looks like the object that has collisionSend enabled only checks for collisions with other objects within the camera view. How can you override this?
Edit #2: I figured out where it is clipping objects that aren't within the view, t2dSceneContainer::findPotentialCollisions. It looks like I am either going to have to detect collisions with every object in the scene or write some custom code for my particular object that I am interested in having collisions.
Associate Phillip O'Shea
Violent Tulip