Enable collision
by Brandon Fogerty · in Torque Game Engine · 07/04/2007 (6:55 pm) · 6 replies
How do you enable collision on a mesh item?
I made my own mesh in Milkshape3d and I wrote the following code for it
datablock ItemData(MBlock)
{
shapeFile = "~/data/shapes/blocks/m.dts";
static = false;
boundingBox = "10 10 10";
};
function MBlock::onCollision(%this, %obj, %col)
{
if(%col.getClassName() $= "Player")
{
echo("COLLISION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}
}
However whenever my player collides with the mesh, he just passes through without any collision. What's up here? Thanks in advance!
I made my own mesh in Milkshape3d and I wrote the following code for it
datablock ItemData(MBlock)
{
shapeFile = "~/data/shapes/blocks/m.dts";
static = false;
boundingBox = "10 10 10";
};
function MBlock::onCollision(%this, %obj, %col)
{
if(%col.getClassName() $= "Player")
{
echo("COLLISION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}
}
However whenever my player collides with the mesh, he just passes through without any collision. What's up here? Thanks in advance!
#2
I select the Collision Mesh -> Bounding Box option. However I still don't get any collision in the game. Do you know what is happening? Thanks in advance!
07/04/2007 (8:34 pm)
Eric, thanks for your reply. When I export my model via the Torque DTS plugin in Milkshape, I select the Collision Mesh -> Bounding Box option. However I still don't get any collision in the game. Do you know what is happening? Thanks in advance!
#3
07/04/2007 (8:38 pm)
Also, can I only do box based collision with the Torque Game engine or can I do ploygon based collision? Thanks in advance!
#4
07/04/2007 (10:55 pm)
In MS3D you can use any Concave shape and use it has a bounding box. Just rename the object "Collision1". Then in the export, where it says Collision Mesh, select the Collision Meshes option. The object will not be visible in TGE, and the object you made will be used as your bounding box.
#5
07/05/2007 (6:10 am)
Maxwell, thanks for the info. However can I make multiple collision meshes for the same model? Can I have say a Collision1, Collision2, Collision3, Collision4, etc bounding boxes for my mesh? Thanks in advance!
#6
07/05/2007 (5:14 pm)
Maxwell, I can't get the collision to work. I made a collision box that covers my model. I named its Group "Collision1" and selected Collision Mesh on the Torque DTS export plugin. IN the game, the object obeys gravity but I can still walk in the middle of the object. What is wrong?
Torque Owner Eric Johnson