Standing on a .dts and using onCollision
by Jake Callery · in Torque Game Engine · 03/21/2007 (6:01 am) · 11 replies
Hey guys, hopefully I'm just missing something here.
Lets say I make a cube as a dts shape, and bring it in.
Then I set up an onCollision event for it, so when I walk through it
it echos something to the console.
That part works fine.
Now however I would like to be able to set it up so that my character
can stand on top of (or simply not be able to walk through) the cube
and still have the onCollision called.
Right now if I bring the .dts in as a static shape, I can stand on it, but there is no
way to call onCollision
Is there a var in the datablock that I might be able to set so the player can't pass through, or a
special collision mesh that needs to be set up?
thanks for the help!
Jake
Lets say I make a cube as a dts shape, and bring it in.
Then I set up an onCollision event for it, so when I walk through it
it echos something to the console.
That part works fine.
Now however I would like to be able to set it up so that my character
can stand on top of (or simply not be able to walk through) the cube
and still have the onCollision called.
Right now if I bring the .dts in as a static shape, I can stand on it, but there is no
way to call onCollision
Is there a var in the datablock that I might be able to set so the player can't pass through, or a
special collision mesh that needs to be set up?
thanks for the help!
Jake
#2
Took this from a maya export page:
03/21/2007 (6:16 am)
Your object needs a collision mesh. The collision meshes start with Col or LOSCol. Col-1, Col-2, etc.. Took this from a maya export page:
Collision_1 through Collision_9: These are collision markers. Col_1 through Col_9: These are the actual collision meshes. LOS_9 through LOS_15: Markers for line of sight, or "bullet", collision shapes. LOScol_9 through LOScol_15: Geometry for line of sight collision.
#3
I think the issue you have here is that you do not have any collision meshes in your model. Apart from the model itself, you need to add extra collision meshes if you want your characters to collide with them. Check the instructions for naming collision meshes for your particular modelling program. If it's Maya, I can give you a hand there.
--Amr
03/21/2007 (6:25 am)
Hi Jake.I think the issue you have here is that you do not have any collision meshes in your model. Apart from the model itself, you need to add extra collision meshes if you want your characters to collide with them. Check the instructions for naming collision meshes for your particular modelling program. If it's Maya, I can give you a hand there.
--Amr
#4
My StaticShape thread
03/21/2007 (6:32 am)
It is true you have to have a collision mesh, but that won't help if the object is loaded in the game as a StaticShape. My artist provided me with a fully prepared item (a briefcase) that had the collision mesh, bounding box, and the whole 9 yards, but because it was a StaticShape there was no onCollision with it. Not unless you modify the source. Let me find the links chronicling this...more to comeMy StaticShape thread
#5
The cube object that I'm using is from the superbomb tutorial on the codesampler.com pages.
(http://www.codesampler.com/torque.htm --- shapes and basic collision tutorial)
It detects a collision, and thus calls onCollision, however the player can walk right though it.
(this cube is not being brought in as a static shape, but a regular shape with a datablock associated
with it)
so if the object does not have a collision mesh, will onCollision still be called? If so, if I make a collison mesh for it, will I then not be able to walk though it, yet still have onCollision called?
Unfortunately I can't try this until I get home from work.
thanks again!
Jake
03/21/2007 (6:39 am)
Wow! that was really fast. You guys are awesome thanks!The cube object that I'm using is from the superbomb tutorial on the codesampler.com pages.
(http://www.codesampler.com/torque.htm --- shapes and basic collision tutorial)
It detects a collision, and thus calls onCollision, however the player can walk right though it.
(this cube is not being brought in as a static shape, but a regular shape with a datablock associated
with it)
so if the object does not have a collision mesh, will onCollision still be called? If so, if I make a collison mesh for it, will I then not be able to walk though it, yet still have onCollision called?
Unfortunately I can't try this until I get home from work.
thanks again!
Jake
#6
03/21/2007 (6:46 am)
Following what mb and Amr said, yes, onCollision will still be called and the player will not walk through the object if it is not a StaticShape and has a collision mesh + bounding box
#7
03/21/2007 (6:49 am)
Excellent! Thanks very much!
#8
It has a bounding box, collision mesh, and three levels of detail.
In showTool Pro, the object shows up fine, and the collision mesh is listed and is displayed.
When I go into the tutorial.base and create the object, it displays fine.
Also the onCollision works, however I can still pass through the object.
here is a link to my data files if any one has a quick second to look to make sure
I have done this correctly:
www.massivepoint.com/torque/collisiontest.zip
My Datablock:
My Create:
And finally my Callback:
Any ideas?
Again thanks for the help!
03/21/2007 (5:13 pm)
Ok, so I've made a new object in Maya by following the dts exporter instructions.It has a bounding box, collision mesh, and three levels of detail.
In showTool Pro, the object shows up fine, and the collision mesh is listed and is displayed.
When I go into the tutorial.base and create the object, it displays fine.
Also the onCollision works, however I can still pass through the object.
here is a link to my data files if any one has a quick second to look to make sure
I have done this correctly:
www.massivepoint.com/torque/collisiontest.zip
My Datablock:
datablock ItemData( JakeColBlock )
{
// The mission editor uses the "category" variable to organize this new
// item under the "shapes" root category.
category = "JakeStuff";
shapeFile = "~/data/shapes/jakeBlocks/jakeColBlock.dts";
};My Create:
function ItemData::create( %data )
{
echo( "ItemData::create for Jake Block Called!" );
echo( " The Data:"SPC%data);
%obj = new Item()
{
dataBlock = %data;
static = true;
};
return %obj;
}And finally my Callback:
function JakeColBlock::onCollision( %this, %obj, %col )
{
echo( "JakeColBlock::onCollision called ----------------------------------" );
}Any ideas?
Again thanks for the help!
#9
Thanks!
03/21/2007 (5:22 pm)
Oh, and I have also tried "checking" the collidable box and unchecking the rotate box in the property inspector, saving the mission, and then reloading the mission. It stopped rotating, but I can still walk through the object.. booo.. :)Thanks!
#10
I've noticed the bug where you type in the coords. for the shape manually and the collision mesh
doesn't go with it. This happens with static shapes, but not items.. so I fear the collison mesh is simply
ignored on an item.
Its looking like its not possible through script.
Can someone point me to the right place in the engine so I can start looking into
modifying the code?
Where can I see the itemData datablock and the staticShapeData datablocks?
I figure I might be able to modify staticShapeData to support a type of onCollision callback
of some sort.
Thanks for the help thus far!
Jake
03/22/2007 (3:26 pm)
Has anyone actually tried to do this here?I've noticed the bug where you type in the coords. for the shape manually and the collision mesh
doesn't go with it. This happens with static shapes, but not items.. so I fear the collison mesh is simply
ignored on an item.
Its looking like its not possible through script.
Can someone point me to the right place in the engine so I can start looking into
modifying the code?
Where can I see the itemData datablock and the staticShapeData datablocks?
I figure I might be able to modify staticShapeData to support a type of onCollision callback
of some sort.
Thanks for the help thus far!
Jake
#11
engine\game\staticShape.h/cc
I had to do the same thing. . .
If you still have problems just (depending on your compiler) pres ctrl+shift+f and look for StaticShapeData or ItemData....should take you right to it.
03/22/2007 (4:50 pm)
Engine\game\item.h/ccengine\game\staticShape.h/cc
I had to do the same thing. . .
If you still have problems just (depending on your compiler) pres ctrl+shift+f and look for StaticShapeData or ItemData....should take you right to it.
Employee Michael Perry
ZombieShortbus