- Home /
Get player pulled to position/object
I'm sure it's simple, but I don't get it:
How can I make that my player gets pulled to something? I tried something like rigidbody.addForce() etc.
By the way I am using c#. Thank You!
Comment
Best Answer
Answer by robertbu · Apr 23, 2014 at 07:01 PM
Assuming your player has a reference to that something that is pulling:
rigidbody.AddForce((something.position - transform.position).normalized * someForce);
Or assuming the something has detected the player and needs to pull it in:
player.transform.rigidbody.AddForce((player.transform.position - transform.position).normalized * someForce);
If it is a force applied over time, then put the code in FixedUpdate.
Your answer
Follow this Question
Related Questions
Problem with player movements 1 Answer
Using var as a placeholder for velocity... why? 2 Answers
OnCollisionEnter not being called, between a Rigidbody and a Box Collider 1 Answer
Distribute terrain in zones 3 Answers
Force to Velocity scaling? 2 Answers