- Home /
How can I make my player push objects?
I'm making a 2.5 D action game and i want my player to be able to push desks to use as barricades. My desks have joints so that I can fake destructible objects. I want my player to be able to attach to the desk from one side and be able to push or pull. How can i accomplish this? No scripts needed just show me links or tell me what to do thanks!!
Answer by tyjkenn · Apr 30, 2013 at 05:14 AM
Use OnCollisionStay. Check if the contact point is left or right of the player. If contact.x-position.x > 0 it is to the right. If it is <0, it is to the left. Also add some conditions on y to make sure it is at pushing height. If the player is moving in the same direction, add a force to assist with the push. If a button is also being pressed (for holding) and the player is moving away, translate the object with the player.
During the pushing, you could temporarily change the joint variables. Disable it, or set the break force and torque to infinity. Then change it back when you lose contact.
Yes but i have joints on the object. It will break the joint or move it out of proportion. How do i do this without disturbing the joints
Your answer
Follow this Question
Related Questions
Cube collision problems when held 0 Answers
What is the best way to Push or Pull an Object? 2 Answers
Amnesia like objects, in unity. 2 Answers
adding Up force 0 Answers