Clarification on Collision Groups
by Jacob Vann · in Torque Game Builder · 09/30/2005 (9:44 pm) · 0 replies
Does setCollisionMasks *only* apply to sent collisions?
Will two sprites collide if they both *only* send collisions (and don't receive them)?
I'm struggling with collisions between my monster and hero sprites. It seems that collision callbacks are being called even when they shouldn't.
My question regards the setCollisionMasks() and setCollisionActive() functions.
setCollisionActive sets whether a sprite sends and/or receieves collision messages.
setCollisionMasks sets which groups that a sprite will send collisions to.
Hypothetical (turn off your pedantic hat, this is a demonstration):
My hero is in group 0
My monster is in group 1
I set my hero's collision mask to BIT(1) and the CollisionActive to (true, false) (only send collisions, and only to the monster group)
I set my monster's collision mask to BIT(0) and the collisionActive to (true, false) (only send collisions, and only to the player group)
You would think that nothing would collide, since neither party is receiving collisions.
However, with this setup, when the hero and monster collide, the onCollision gets called twice, once for monster on player, and again for player on monster. From what I understand, onCollision should not get called. At all.
Is this expected behavior, or is there something wrong in my code that could be the culprit? I also have a tile layer that is set to CollisionActive(false, true), and both monster and hero collide with it just fine.
What I want in the end is the monster to send *and* receive collisions (send to the tile layer, receive from the player), and the player to only send. With this I get the same behavior, even though you'd only expect the monster to receive a collision from the player, and not vice versa.
Thanks for any insight. It's driving me nuts!
(I'm going to build a stripped down example)
-Jacob
Will two sprites collide if they both *only* send collisions (and don't receive them)?
I'm struggling with collisions between my monster and hero sprites. It seems that collision callbacks are being called even when they shouldn't.
My question regards the setCollisionMasks() and setCollisionActive() functions.
setCollisionActive sets whether a sprite sends and/or receieves collision messages.
setCollisionMasks sets which groups that a sprite will send collisions to.
Hypothetical (turn off your pedantic hat, this is a demonstration):
My hero is in group 0
My monster is in group 1
I set my hero's collision mask to BIT(1) and the CollisionActive to (true, false) (only send collisions, and only to the monster group)
I set my monster's collision mask to BIT(0) and the collisionActive to (true, false) (only send collisions, and only to the player group)
You would think that nothing would collide, since neither party is receiving collisions.
However, with this setup, when the hero and monster collide, the onCollision gets called twice, once for monster on player, and again for player on monster. From what I understand, onCollision should not get called. At all.
Is this expected behavior, or is there something wrong in my code that could be the culprit? I also have a tile layer that is set to CollisionActive(false, true), and both monster and hero collide with it just fine.
What I want in the end is the monster to send *and* receive collisions (send to the tile layer, receive from the player), and the player to only send. With this I get the same behavior, even though you'd only expect the monster to receive a collision from the player, and not vice versa.
Thanks for any insight. It's driving me nuts!
(I'm going to build a stripped down example)
-Jacob