Game Development Community

Given object id, how to damage it?

by Nikhil Haldar-Sinha · in Torque Game Engine · 07/29/2006 (7:53 pm) · 1 replies

I've used the ContainerRayCast ( startPos , endPos , mask [ , exempt ] ) function to find out what it hits. The docs say it "Returns 0 if no objects were struck by the ray, or a non-zero integer representing the ID of the object that was struck." So given the ID, how do I get the player it hit and apply damage to it?

Thanks.

-Nick

#1
07/29/2006 (10:32 pm)
When you use the ContainerRaycast, store it's return in a variable. The first value in the return will be the id of what it hit, so you can do something like.
%damageRaycast = ContainerRaycast( blah...)

if(%damageRaycast.getType() & $TypeMasks::ShapeBaseObjectType)
 %damageRaycast.damage(blah...);