- Home /
How to pull and push, jedi-style?
So, for my game, I want to left click to throw the enemy toward me, and right click to send the enemy flying away from me. Can anyone help me with this?
Answer by ariesanu_stephan · Jun 06, 2014 at 08:11 PM
Hi,
the pushing part should be quite easy if you are using rigidbodies. You just have to add a script, that applies a force, to the object you wish to push/pull. You can see a tutorial on that here. To make the script trigger you can use a raycast and check if the raycast hits anything. Raycasts are explained here.
The pulling part is a bit harder, as you need to make sure that the object you are pulling will not hit you and push you backwards(try creating a trigger around the main character and make the object you are pulling stop or float in front of you if it enters the trigger).
I hope this helped.
Your answer
Follow this Question
Related Questions
sucking in particles 3 Answers
How can I make my player push objects? 1 Answer
Pulling objects 2 Answers
What is the best way to Push or Pull an Object? 2 Answers
How to Check Collision When Pushing / Pulling Object in 3D Space 0 Answers