Game Development Community

Determining which tile was collided with

by Dan Hargrove · in Torque Game Builder · 09/16/2005 (3:00 pm) · 1 replies

I've also been playing with the tile map and got it to recognize collisions with a ball for my attempt at learning T2D with a Breakout clone. One question I have is, is there a way to determine which tile has been collided upon within the onCollision event?

I was playing around with the onTileScript event hoping to see if there was a way to set a type, or a flag, or name, or whatever, and then check the source and/or dest objects within the onCollision event. My hope is to clear the tile - though, I'm not sure I can do that just yet (I'm checking the docs now).

Thanks

#1
09/17/2005 (2:08 am)
Dan,

The answer is yes. In the "onCollision()" callback, srcRef$ and dstRef$ are custom strings passed-back by the colliding objects. As it mentions in the callback doco, only the tile-layers uses this currently as they pass-back the logical tile x/y which you can then use for further examination of the tile details.

This was primarily provided to allow objects that are containers of other objects to pass-back more detailed information as is the case in the tile-layers.

Hope this helps,

- Melv.