Game Development Community

Basic physics for Torque 1.4 not working

by DreamPharaoh · in Torque Game Engine · 06/01/2006 (11:25 pm) · 15 replies

I have bought 2 books and spent 2 weeks searching forums and still can not find clear resolve to this issue. Gamers are currently looking for intereactive content in the games they play such as Oblivion when the player hits a table and the objects fly off of it. This is simular to what I am trying to do.
I have found in the forums Thomas's RigidShape zipp code, but this is for 1.3 and not 1.4. After I recompile it I have list of datablock errors within the script to the functions that Torque decided (for some reason) to change.
I am working with a chair currently that has a collision mesh. When I make it a static object then I can jump ontop of it with the blueguy, but it obviously will not move. When I make it rigid with the below code the chair reacts to gravity and falls but the blueguy will walk through the chair although the engine states that a collision has occured.

Code ......................................... hacked from another source.

datablock ItemData( Chair )
{
// The mission editor uses the "category" variable to organize this new
// item under the "shapes" root category.
category = "rigidData";
mass = 500;
massCenter = "0 0 0"; // Center of mass for rigid body
massBox = "0 0 0"; // Size of box used for moment of inertia,
// if zero it defaults to object bounding box
drag = 0.2; // Drag coefficient
bodyFriction = 0.2;
bodyRestitution = 0.1;
minImpactSpeed = 5; // Impacts over this invoke the script callback
softImpactSpeed = 5; // Play SoftImpact Sound
hardImpactSpeed = 15; // Play HardImpact Sound
integration = 4; // Physics integration: TickSec/Rate
collisionTol = 0.1; // Collision distance tolerance
contactTol = 0.1; // Contact velocity tolerance

minRollSpeed = 10;

maxDrag = 0.5;
minDrag = 0.01;

triggerDustHeight = 1;
dustHeight = 10;

dragForce = 0.05;
vertFactor = 0.05;

normalForce = 0.05;
restorativeForce = 0.05;
rollForce = 0.05;
pitchForce = 0.05;


// Next, we'll tell the mission editor where to find the .dts shape file
// that defines our Super Bomb's geometry.
shapeFile = "~/data/shapes/Chair/Chair.dts";
};

//-----------------------------------------------------------------------------
// The mission editor will invoke this create() method when it wants to create
// an object of our new datablock type. This is a good time to setup any
// default behavior for our object. For example, our new object's default
// behavior is to be unmovable or static and rotate in place.
//-----------------------------------------------------------------------------
function ItemData::create( %data )
{
echo( "ItemData::create for SuperBomb called --------------------------" );

%obj = new Item() {
dataBlock = %data;
rotate = false; // All Super Bomb power-ups will rotate.
static = false; // Super Bombs should stay put so they don't slide away.
};

return %obj;
}

//-----------------------------------------------------------------------------
// And, of course, what good is a Super Bomb power-up if we can't tell when
// the player is touching it? Every time our player touches a Super Bomb the
// onCollision() function below will get called.
//-----------------------------------------------------------------------------
function Chair::onCollision( %this, %obj, %col )
{
echo( "SuperBomb::onCollision called ----------------------------------" );

// TO DO: Add code here to have the player react to touching the power-up!
}

#1
06/02/2006 (12:03 am)
Have you considered using PhysX instead?
#2
06/02/2006 (8:11 pm)
Thankyou Martin I will check this out. This is a stupid problem to have noting that torque uses the required physics throughout the system for vehicals and other objects yet this obvious version is not in the engine core. Very frustrating.
#3
06/02/2006 (8:29 pm)
If I am reading this right I m little sleep right but RigidShape will work with TGE 1.4 and TLK 1.4. I have it working in both. If you need help to get this to work let me know.
#4
06/02/2006 (9:42 pm)
The PhyX resource is a work in progress... doesn't support terrain or player collsions. so it's not that great.



Quote:
After I recompile it I have list of datablock errors within the script to the functions that Torque decided (for some reason) to change.

can you post the "errors" you're getting. that would probably help explain why it's not working for you.
#5
06/03/2006 (7:06 am)
I took a look at Phyx and noticed it probably will end up causing me more problems then solving. Ramen if you are willing to help I would greatly appreciate it. I have been working on this for 2 weeks now without resolve. I even tried using vehicle physics but the shape rolls upside down. Anyway I downloaded and attempted to compile the Rigidshape but it will just error this portion out and compile the rest of the game engine. It appears that the function names are different from 1.3 to 1.4 causing this issue. Irregardless please direct me on how this is done.
Thank you
#6
06/03/2006 (4:55 pm)
Sorry I overlooked your request for the error information. I get this error below which tells me that the engine core still does not know what this is even after recompiling the scripts into the engine folder. I was wondering if I need to add any lines of code to the engine core to get the RigidShape scripts to run. I am not sure how all of this works so I followed the instructions step by step.

GameOne/server/rigidShape.cs (0): Unable to instantiate non-conobject class.
#7
06/03/2006 (6:30 pm)
I really need an example of how to make an object move in the game when a player hits it. When I add an object as TSSstatic it will have a collision mesh. As soon as I create it as an item it renders the collision mesh inactive. There is even a field in the gui to enable collidable. When I click this it does nothing. I have added the below code to the player which should impart at least an impulse to the object, yet nothing. I am not understanding why the objects in torque are so oblivious to any collisions or movement. It looks like from the forums that rigid shape will soon be added that will allow what I am trying to do. I would greatly appreciate any simple object example with code that does any movement from collision so that I can learn how it currently works.

if (%col.getDataBlock().getName() $= "Chair") {
// Apply an impulse to the object we collided with
%eye = %obj.getEyeVector(); // if no eye node then Torque gets point centriod instead, supposedly
%vec = vectorScale(%eye, 4);

// Set the object's position and initial velocity
%trans = %col.getTransform();

// Heres the position and rotation.
%pos = getWords(%trans, 0, 0.5);
%col.applyImpulse(%pos,%vec);
}
}

Thank you
#8
06/03/2006 (9:15 pm)
Friction or drag may be the culprit. try messing with the object properties and try increasing the amount of impulse your applying.

%pos = getWords(%trans,0,0.5);

i dont think this is what you want. What are you trying to do here?

i think it should be

%pos = getwords(%trans,0,2);
#9
06/03/2006 (9:40 pm)
Sean,

The collision mesh on the objects (in this case a chair I made from milkshape with collision mesh added) will not render it's collision with the player unless it is a TSSstatic shape. I just feel that it will be important for my RPG to have dynamic objects that respond to a player when they bump into it. The game Oblivion has this- just bumping the table will knock all the objects off of it. It seems like a simple thing that has turned out to be way more complicated than it needs to be. I wish I could import the physics of Blender- it was not even a remote problem. In Torque it seems to be some type of federal case to allow any object thats effected by gravity to intereact with the player. The objects act like ghosts to the player. I just could not possibly imagine this being even an issue. I'm wondering if I have a defective version because something like this is so trivial from what I am used to.
#10
06/03/2006 (10:13 pm)
Chad youre right. i dont think torque was made to support complex object interactions like that by default. for the kind of stuff you want you're either going to have to write your own physics code, or just script the behavior you want. whatever you do, you're probably not going to get the level of interaction you see in Oblivion.
#11
06/03/2006 (10:27 pm)
Right now I would just be thankful for a box that moved in any way shape or form from a player hitting it, just something. I really need an example to pull from. It is the only way I can learn. I will then give the finished script to help others out. I guess I will wait for the Torque developers to add this in. This is not a worthless need because it is the new craze and expectation from game players of RPG games and other game formats. In other words it is absolutly not a request but an expectation from us game creators and hast to be implimented, otherwise we are wasting our time in this Torque utopia. There is only going to be so many Marbleblasts that will be digested by the public.
#12
06/03/2006 (11:59 pm)
Child, be quiet and stop whining about pointless physics. I'm getting fed up with all this complaining over physics when I don't see any games making a good use of it. Oblivion's physics are 100% fluff, they are only there because they can afford to have it (licensed Havok), and because they are a major developer/brand so people expect these things from them. You're not going to make anything that's going to approach or compete with Oblivion on any fronts, so things like that are the least of your worries. Having the "latest craze" and what you see in all the commercial games is not going to let you make an interesting game. You can't compete with them so try and focus on offering something they don't, instead of worrying about what features you can copy from them.
#13
06/04/2006 (8:13 am)
Oblivion is just an example. The concept was the point. The problem here is items do not move in any way shape or form when in contact with a character. Do you think that any game can get away with that? I dont know of too many kinds of games that the player won't think "huh that's wierd that I pass through all the furnishings, or that's wierd nothing moves."

I'm actually not looking for a discussion on the matter just a probable solution to the problem.

Thank you,

Added:

Found further confirmation that this is an issue that many are having and Torque developers are currently working on it. I would imagine that to have noobs with access to this type of collision would increase the chances of the engine crashing. It eats a lot of CPU power for collisions and to have a multiplayer game with everyone hitting objects could be a real problem. I am currently working on modifying the rigid script- once it is stabilized I will post it here for everyone else.
#14
06/05/2006 (4:27 pm)
@Paul:
Quote:Child, be quiet and stop whining about pointless physics. I'm getting fed up with all this complaining over physics when I don't see any games making a good use of it. Oblivion's physics are 100% fluff, they are only there because they can afford to have it (licensed Havok), and because they are a major developer/brand so people expect these things from them. You're not going to make anything that's going to approach or compete with Oblivion on any fronts, so things like that are the least of your worries. Having the "latest craze" and what you see in all the commercial games is not going to let you make an interesting game. You can't compete with them so try and focus on offering something they don't, instead of worrying about what features you can copy from them.
That was constructive. =(

Just fluff in Oblivion? Maybe in your opinion. But the increase in the level of immersion is sure worth it. How about a less "fluffy" example then: Half Life 2. In many places the physics are integral to solving the game. And why such a negative and unhelpful post? How do you know what others can and can't do??? If you're not willing to help Chad or provide positive feedback, then why post?!

There are many of us in the Torque community that would wholeheartedly welcome a solid physics solution fully integrated into the engine. I know I would, since the current physics implementations are separated from each other (i.e. one for the player, one for flying vehicles, one for hover vehicles, etc. ) and there is no easy way to extend it. Bringing it all together under one implementation/API would be huge. If I felt like I had the time to spend on it, I'd be working on a solution. But other things demand my time right now.

So keep at it, Chad. I for one look forward to anything you can throw our way. =)
#15
06/05/2006 (5:51 pm)
Kevin,

I appreciate your support. I will definitly keep working at this- After looking at the engine source I realized that it is way over my head right now on how it all comes together. So I will be paying a programmer from our local Votech within the next 2 weeks to help me out on this issue. Sometimes my sarcasim comes across a little rude. Usaully I control it but I really view this issue seriously. That is why I am willing to pay for help on it.

Take Care- I will keep everyone up to date,