- Home /
Add force on objects from a specific location in space
Hi. I'm trying to create some sort of a jet stream that rises from the floor, and if a rigidbody is wandering above that jet stream, it will get tossed around.
To my understanding, I can add force to objects, but I don't think I can actually make an object that spews out force.
Is the only way to do this by checking the position of each rigidbody, and if any are above the jet stream then add force (at position) to those bodies?
Also, how does AddForceAtPosition work? What is the position var exactly? A position limited to the body boundaries? a position in space?
Thanks for any help!
rigidbody.AddExplosionForce()? You will still have to apply this to each rigidbody..
Answer by rutter · Mar 27, 2012 at 09:03 PM
Also, how does AddForceAtPosition work? What is the position var exactly? A position limited to the body boundaries? a position in space?
`AddForce()` simply adds force to the rigidbody. It's simple and works in most cases, but can't model some interactions that require more control.
`AddForceAtPosition()` does the same thing, but also allows you to specify where the force is coming from -- you can think of this as modeling the point of contact when you "push" something. There's no absolute requirement that the position is inside or even close to your rigidbody, but your results will probably seem more realistic if it is.
If you've studied some physics, the key difference between the two functions is whether you're treating the rigidbody as a point particle or not. Adding a force at a specific position can also apply torque, causing your object to spin.
Thanks, that cleared up my confusion about the position parameter.. Regarding my other question, if you have some insights and time: If I RayCast upwards from a point on the floor, and add an Upwards Force (from the position of that floor point with addforceatposition) to any object that intersects that ray, then it should theoretically simulate a jet of air co$$anonymous$$g from the floor, right? Thanks.
Sounds workable?
If you're intending to create persistent zones of effect, you could also try using a trigger collider to notify objects when they've entered a "force zone" (which they can then react to appropriately).
As far as the force position, that's a bit more complicated. Remember how I mentioned that you could think of the force position as a "point of contact"? Far-away points will cause more spin -- you can think of it as a sort of "lever arm", with longer and more angled levers producing more rotational push.
Answer by Zero_Zagarth · Sep 27, 2012 at 07:22 PM
Hey men, that post should help you. http://answers.unity3d.com/questions/248788/calculating-ball-trajectory-in-full-3d-world.html There are any answer called BallisticVel and that works very nice! I hope it's useful for you.
Have a nice day!
Your answer
Follow this Question
Related Questions
Unity 2019.3.0f6 - Trouble with physics, cubes turn left after some meters 1 Answer
How to decrease inertia for a rolling ball 1 Answer
Object jumping while moving(with addForce) 0 Answers
add force to object that has 2 different rigid bodies 0 Answers
Confusion with AddForce with ForceMode.Acceleration 1 Answer