- Home /
Simple Rigidbody / force question
This seems to be something that would be used in a lot of games, but I can't find an answer to this.
What I want to do:
My player will contanstantly be hit by spheres, as she is hit with a sphere I wish to add force relative to the direction the sphere was heading and depending on where the player was hit.
For example if the player was hit on the left side by a sphere heading in the X direction, I would want the player to fly off in the x direction, with some z direction because she wasn't hit in the center, she was hit on the side. If she was hit in the center she would head directly in the x direction.
I cant seem to add a picture, heres a link. I hope it helps. http://imageshack.us/photo/my-images/444/forceq.jpg/
The only solutions i've encountered is to add a physic material to the player, such as Bouncy, and give the spheres great mass. However I cannot do this in my game because it is networked.
Thanks in advance!
Answer by kevork · Nov 05, 2011 at 06:34 AM
The simplest way would be to use Rigidbody.AddExplosionForce when you detect the collision, otherwise you can use Rigidbody.AddForce.
Answer by vivalarosa · Nov 05, 2011 at 09:47 AM
Thanks, i know how to add the forces but i need to add the forces depending on where the player was hit. I presume it has something to do with adding collision from the collision point in the same velocity that the object was heading - an offset accounting for where in the rigidbody it was hit.
Answer by vivalarosa · Nov 14, 2011 at 12:21 AM
Does anyone know how to do this? As mentioned it would seem like a pretty common thing. Another example would be a player being hit by a car, you'd want the player to be pushed in the direction the car hit you and if you were hit on the side, you'd fly off to the side a bit.
Your answer
Follow this Question
Related Questions
Character Controller meets Rigidbody 1 Answer
add force to object that has 2 different rigid bodies 0 Answers
How to apply uni-directional force to a rigidbody 0 Answers
chain and 3rd person character 0 Answers