Game Development Community

Snippet: onCollision Shape Index Order.

by practicing01 · in Torque 2D Professional · 01/24/2014 (4:34 am) · 0 replies

The onCollision and onEndCollision callbacks for a SceneObjectA and a SceneObjectB set shapeIndexA to always be the first parameter and shapeIndexB to always be the second parameter. Unless you check which callback was called first, you won't know which SceneObject is A and which is B, you won't know which Index belongs to which SceneObject. Here is a simple copy/paste method of ensuring the SceneObject checking its onCollision will have its shapeIndex be the first parameter.

https://github.com/practicing01/Torque2D/commit/d2272a7658d4da1d17862308c5e53a095baf02fa