x


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!

more ▼

asked Mar 27 '12 at 08:07 PM

sndwav gravatar image

sndwav
5 2 2 2

rigidbody.AddExplosionForce()? You will still have to apply this to each rigidbody..

Mar 27 '12 at 08:20 PM Branx
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Mar 27 '12 at 09:03 PM

rutter gravatar image

rutter
5.2k 2 11

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 coming from the floor, right? Thanks.

Mar 27 '12 at 09:14 PM sndwav

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.

Mar 28 '12 at 03:24 AM rutter
(comments are locked)
10|3000 characters needed characters left

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!

more ▼

answered Sep 27 '12 at 07:22 PM

Zero_Zagarth gravatar image

Zero_Zagarth
1 1 2

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1868
x1787
x244
x10

asked: Mar 27 '12 at 08:07 PM

Seen: 941 times

Last Updated: Sep 27 '12 at 07:22 PM