Game Development Community

Removing "collisions" from stacked objects

by Kevin Lu · in Torque Game Builder · 12/30/2009 (12:09 am) · 2 replies

I have a game where I am stacking boxes, one on top another. Boxes fall out of the sky, and when the topmost box hits a falling box they begin to stack. When a box stacks, the topmost box has "collision" active, however, all other boxes underneath them have "collision" attached to them as well. How do I remove the collision functionality from all but the topmost box? Anyone have any ideas?

Any help would be greatly appreciated!

Thanks in advance.

-Kevin

#1
12/30/2009 (9:00 am)
The easiest solution would be to enable a collision callback, and check it either as a class function (if you're implementing the boxes' logic with classes) or a behavior function. Note that this would be onCollisionCallback. If you need to check the direction the collision happened from, you can do a comparison of the collision normal passed as a parameter to the onCollisionCallback method, so it should at most require a quick trip to the reference docs to make sure you cover all of your bases.

If you need any more specific help, I can whip up a small sample.
#2
01/12/2010 (7:21 pm)
Ken,

Thanks for the reply. I figured out that by just turning off the collision for the src object - %srcObj.setCollisionActive( false, false ); - I achieved the desired effect. However, I am still curious as to how one would check the direction the collision happened from (and perhaps at what specific point). Mind if I take you up on your offer for a small sample? :)

Thanks!