Game Development Community

How to get player to push physics objects?

by Paul Clarke · in Torque 3D Beginner · 06/02/2013 (7:46 am) · 4 replies

I've searched and searched for this but can't seem to find an answer. I'm using bullet and have got some simple PhysicsShapeData objects in my game, everything works fine except when the player collides with them it's like hitting a brick wall. What I want is for the object to get pushed out of the way instead of causing the player to stop moving, basically like the typical crates and boxes that you'll find in a lot of games. Any help is appreciated.

#1
06/02/2013 (8:28 am)
I think there was a thread on this not too long ago in the professional section. Basically you need to code up a onCollision call with the physics shape and have it detect if the object colliding with the physics shape is a player. If the object is a player, you apply an impulse to the physicsShape using the player's forward vector (or whatever direction you want it to use)
#2
06/02/2013 (9:18 am)
I'll redirect you to this link that has some sample code for applying an impulse upon collision:

http://www.garagegames.com/community/forums/viewthread/134111/1#comment-844481

Hopefully this can give you a push in the right direction.
#3
06/02/2013 (12:38 pm)
Thanks for the link, I tried that code but unfortunately it doesn't seem to work with physicsShape. I'm not really a programmer so I don't know where to go from here.
#4
06/03/2013 (7:28 pm)
Here is a post I made that might help:
http://www.garagegames.com/community/forums/viewthread/130395

Upon reading your question again I don't think you are trying to do that.

If your physicsShapes have a mass of 0 they will not move when the player (or with the applyImpulse function) hits them.
Go to your physicsShapeData block and make sure it has a Mass of more than 0.