How can I tell what I collided with?
by Brandon Mckee · in Torque X 2D · 11/25/2007 (7:13 pm) · 6 replies
Public static void OnCollision(T2DSceneObject ourObject, T2DSceneObject theirObject, T2DCollisionInfo info, ref T2DResolveCollisionDelegate resolve, ref T2DCollisionMaterial physicsMaterial)
In TXB, for a scene object, I set a Name in the Scripting rollout. How can I get to that name for theirObject?
In TXB, for a scene object, I set a Name in the Scripting rollout. How can I get to that name for theirObject?
About the author
#2
11/26/2007 (3:43 pm)
That doesn't seem to work for spawned templates. I have to name the template, and I can name the spawner, but .Name is still empty.
#3
11/26/2007 (3:56 pm)
@Brandon - Names need to be unique, so spawned/cloned objects don't have their names set to anything. Can you achieve what you want another way, maybe with the use of object types or something?
#4
11/27/2007 (7:51 am)
Object types, yes, but is there a "second tier" something I could use to identify the object? I was thinking I wanted 5 to 10 types: player, enemy, environment, item, ect. Then 10s of environemnts, 100s of enemies, and 100s items. The initial collision would only need to check against a few types, then the followup function could process more in depth information. Should I create a component to hold that information, so I can set it from TXB? How do I get to an object's component public properties?
#5
11/27/2007 (8:18 am)
@Brandon - Yes, that's probably what I'd do. I assume you mean how do you get them from C# code?StatsComponent theirStats = theirObject.Components.FindComponent<StatsComponent>();
if (theirStats != null)
{
// object has a statsComponent, so do whatever based on theirStats.environmentType, etc.
}
Torque Owner Joshua A. Thomas