Game Development Community

Collision with same class

by USC - IMD student 2 · in Torque Game Builder · 04/11/2007 (6:14 pm) · 2 replies

Hey everybody, first time poster here.

I'm working on a game where sprites (bubbles) continuously spawn and float upward. As of now, the bubbles correctly collide with the player sprite. The bubbles are set to send collision and collision callback only, and the player is set to send/receive collision, send physics, and callback.

My problem is that I want to code a behavior for when the bubbles collide with one another. For some reason, Torque doesn't seem to allow this. In my onCollision function, I check to see if the destination sprite is of the bubbles class (if(%dstObj.class $= "bubbles")), and even though it is, Torque does not recognize any collisions that occur when the game runs (between the bubble sprites, at least). For full disclosure, I tried turning on receive collision for the bubble sprites, but this caused Torque to crash.

Has anyone else had this problem? Is there an easy away around, or just a difficult way? I'm new to programming, so don't laugh too hard if my problem seems pathetic.

Thanks ahead of time for any help.

#1
04/11/2007 (9:03 pm)
Could it be because your bubbles aren't set to receive collisions?
#2
04/11/2007 (11:36 pm)
Collision in Torque is confusing. Worry not, you're in good company.

Make sure that your bubbles have the correct collision layers and groups on. Set the Layer and Group values of all of your bubbles and then double check that you have the bubbles colliding on that particular group within that particular level.

Say your player is on layer 15, group 1.

Your bubbles all spawn on layer 10, group 0.

If you want the bubbles to interact with the player AND other bubbles you need to make sure that the bubbles collide on Layers 10 and 15 AND Groups 1 and 0 ( the order is whatever ).

That help?