Game Development Community

How you read these variables in Armor::onImpact $10 reward

by Highlander · in Torque Game Engine · 05/28/2007 (3:26 pm) · 4 replies

Heya guys,
I'm working on some collision code and I need help reading some variables from two player objects and setting their velocities afterwards. How do you do it? First person to fill in the brackets correctly gets $10.


function Armor::onImpact(%this, %obj, %collidedObject, %vec, %vecLen)
{
//1 refers to %obj
//2 refers to %collidedObject
//both are player objects

echo("m1="@ ["mass" of 1] );
echo("m2="@ ["mass" of 2] );
echo("v1="@ [Velocity vector for 1] );
echo("v2="@ [Velocity vector for 2] );
echo("n="@ [normal unit vector to the vector from 1 to 2] );

#1
05/29/2007 (2:33 am)
echo(%obj.getDatablock().mass);
echo(%collidedObject.getDatablock().mass);
echo(%obj.getVelocity());
echo(%collidedObject.getVelocity());
regarding the last - see console commands starting with Vector*:
VectorAdd(), VectorCross(), VectorDist(), VectorDot(), VectorLen(), VectorNormalize(), VectorOrthoBasis(), VectorScale() and VectorSub(). Do what you want/need with it.
#2
05/29/2007 (3:26 am)
I believe that the last one would be:
echo("n=" @ VectorNormalize(VectorSub(%collidedObject, %obj)));
Ex:
If %collidedObject was at <3,3> and %object was at <1,1>, then VectorSub would return <2,2> and VectorNormalize would return <1,1>.
#3
05/29/2007 (4:58 pm)
Bank, couldnt find an email address for you so i donated $10 to your afterworld project.

Richard, i wanted the normal vector (perpendicular) to the vector from 1 to 2. Also I think you need .getPosition() after each of the objects?
#4
05/30/2007 (3:36 am)
Highlander, thanks :)