Game Development Community

How to make a player to push a car?

by Yui Chung, Ng · in Torque Game Engine · 07/02/2003 (2:56 am) · 4 replies

I find that in the existing engine, Object (vehicle, player etc) can't tranfer there motional force to the others when collision happen. This causes vehicles to stop right when they touch anything. So time two players jamed and can't walk away when they crash together.

I want to add some code to make the shapebase objects to push each other when collision happen. so that two objects can bounds the other away to avoid jamming. Player can push a car. Car can bounds away another car....etc..

But I don't know the right way to do it. Where (which class? which function?) should I work on? All I know is more object classes has it own code to detech collision and make them move. There seems no unified way to allow all classes to tranfer the motional forec to or from the others. Could anyone gimme some advice?

Thanks a lot.

#1
07/25/2008 (7:07 pm)
It's been 5 years and nobody has answered this man's question. Now I have the same question. Somebody help us!
#2
07/25/2008 (8:13 pm)
Wow, reviving a five year old thread....
#3
07/25/2008 (8:51 pm)
Actually, I found the answer to this and have implemented it in my game. Here is the posting:

http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5495

If you have version 1.5.2, the rigidshape.h and rigidshape.cc he includes in the resource is already there in your original build of Torque, so all you'll have to do is add the script he mentions in his post to your server/scripts directory.
#4
07/25/2008 (10:13 pm)
I think the problem the original poster is seeing is that when a Vehicle (or a RigidShape) collides with something (another Vehicle, a Player), the collision routine it runs treats the other object as immovable. So vehicles will rebound off players and stuff.
This thread www.garagegames.com/mg/forums/result.thread.php?qt=63305 fixes the issue when colliding against vehicles, and down in the thread someone suggests changes for colliding against RigidShapes. If you want Players to be pushed around, look in Vehicle::updateCollision and uncomment the call to resolveDisplacement (and change the parameter 'ns' to 'mRigid').
However, Players still can't push vehicles around (well, maybe they can, but my vehicle's mass is too high...).