Game Development Community

Giving a custom made object physics attributes

by Alaric Karczag · in Game Mechanics Kit · 03/03/2010 (5:14 am) · 3 replies

I have some shapes I've made in blender and exported to tgea. How do I give the objects a physics collision mesh so it works like the others?
I have a chair, let's say, and it's got it's proper col and Los meshes setup properly and I've exported it into tgea. I want to give it a simple box physics collision shape where do I edit the field that it's using for the dts shape?
In the programmers guide it states that the "shapeFile" field is what's used to state the objects dts model. How do I edit this from in game, so I can link a buch of objects into the physics engine?
Thanks again torquers!

#1
03/10/2010 (8:24 am)
In the current version of GMK you can add only one shape for the physics object. So you can approximate chair with only one box.

You have to change shapeType, rotAngles, mass, offset fields to config your physics collision shape.

Look at the 'game\ScriptsAndAssets\server\scripts\logickingMechanics\SampleObjects\rigidBodies.cs'


datablock RigidBodyData( PhysBarrel )
{	
   category = "RigidBody";
   shapeFile =  "~/data/shapes/steel_barrel_green/steel_barrel_green.dts";
   shapeType = $ShapeType::Cylinder;
   rotAngles = "0 0 0 0";
   offset = "0 0 0.5 0";
   mass = 4;
  
   slidingThreshold = 0.7;

   minContactSpeed = 1.0;
   collisionSoundsCount = 1;
   collisionSound[0] = barrelFall0;
   collisionSound[1] = barrelFall1;
   
   slideSoundsCount = 1;
   slideSound[0] = barrelRoll;
};
#2
03/11/2010 (4:01 am)
1. so i have to create a new data block for each item i want physics on?
or, can there only be 1 physics box, and it can only have 1 dts? ie all pysics boxes all have to have the same .dts?

2. a box physics shape for: a stool, a container, and a square trash can, all the same size, would need 3 differnt physics entries? or can i reuse the data?

3. is there an editor to add physics to a .dts shape within the editor? or only via script?

4. if i have 3 differnt physics box types, will they be added to the editor?


sorry for all the questions, i looked at GMK as a way for a non-programmer like myself to be able to add these abilities without scripting. I had hoped that GMK added the useablity factors like UDK has built into thier editors.

thanks again for your help.
#3
03/18/2010 (9:33 am)
Quote:
1. so i have to create a new data block for each item i want physics on?
or, can there only be 1 physics box, and it can only have 1 dts? ie all pysics boxes all have to have the same .dts?


Yes, for each new physics body you'll need separate datablock. Just like in rigidBodies.cs.

Quote:
2. a box physics shape for: a stool, a container, and a square trash can, all the same size, would need 3 differnt physics entries? or can i reuse the data?

You'll need to create new data block for each

datablock RigidBodyData( PhysBox )
{	
   category = "RigidBody";

   shapeFile = "art/shapes/crates/crate1.dts";
   shapeType = $ShapeType::Box;
   mass = 2;
   scale = "0.5 0.5 0.5";
   
   minContactSpeed = 1.0;
   slidingThreshold = 0.1;
   collisionSoundsCount = 3;
   collisionSound[0] = boxFall0;
   collisionSound[1] = boxFall1;
   collisionSound[2] = boxFall2;
};




Quote:
3. is there an editor to add physics to a .dts shape within the editor? or only via script?

Only in script. It's really easy, you have only to put DTS name in shapeFile field of datablock.


Quote:
4. if i have 3 differnt physics box types, will they be added to the editor?

If you need them in the editor you'll need to add templates. Look at the very bottom of rigidBodies.cs. There are some info in programmers guide of how setup templates for editor as well.