Forcing object collision from script
by Jack Stone · in Torque Game Engine Advanced · 08/09/2006 (10:05 am) · 2 replies
I'm trying to implement energy shields for my game, and I need to cause a projectile to "collide" using a script call.
I thought that calling oncollision would do it, but I started digging in the c++ and apparently thats called after the collision occurs.
From what I have found, I believe I need to call ShapeBase::queueCollision(ShapeBase* obj, const VectorF& vec) in order to force the projectile to collide. (in shapebase.cpp)
The only problem is, I can't access that function from script. Is there a way to access that function from script? (Is this where a console method would be used?) or is there a better way of doing what I want to do?
I considered creating a transparent dts object with a collision mesh in front of the projectile at the point that I want the projectile to collide, but that seems really messy, and not very efficient.
Also, if I can get queuecollision to work, what would I pass as the vector parameter?
Thanks for any help,
JS
I thought that calling oncollision would do it, but I started digging in the c++ and apparently thats called after the collision occurs.
From what I have found, I believe I need to call ShapeBase::queueCollision(ShapeBase* obj, const VectorF& vec) in order to force the projectile to collide. (in shapebase.cpp)
The only problem is, I can't access that function from script. Is there a way to access that function from script? (Is this where a console method would be used?) or is there a better way of doing what I want to do?
I considered creating a transparent dts object with a collision mesh in front of the projectile at the point that I want the projectile to collide, but that seems really messy, and not very efficient.
Also, if I can get queuecollision to work, what would I pass as the vector parameter?
Thanks for any help,
JS
#2
08/10/2006 (1:45 pm)
Basically, your just exposing queueCollision to the console. Nice and clean. I'm going to bookmark this, just in case I need it.
Torque 3D Owner Jack Stone
ConsoleMethod( ShapeBase, queueShieldCollision, void , 2 , 4, "(ShapeBase* obj, const VectorF& vec) ")
{
ShapeBase * obj;
VectorF vec(0,0,0);
dSscanf(argv[3],"%g %g %g",&vec.x,&vec.y,&vec.z);
if (Sim::findObject(argv[2],obj)) {
object->queueCollision(obj , vec );
}
}
and I can force any object to collide with any other object from script. It looks pretty cool.
JS