# Change a line composed of vextor3's to a constant.force on an object

 0 Hello and thanks for your attention. I'd like to use a line composed of vector3 vertex positions to apply force to objects, via constant.force, that intersect it. The fiction is: think of a leaf getting caught up in a current of water in an otherwise still pond. The scripting documentation on constant force is a little light. Can I take line segments defined by vextor3's and apply them as (appropriate to fiction) constant forces on objects? Thanks! --Goody! more ▼ asked Nov 18 '09 at 03:20 AM Goody! 516 ● 24 ● 31 ● 46 runevision ♦♦ 8.1k ● 29 ● 46 ● 112 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

2 answers: sort voted first
 0 First have a look at the documentation for Rigidbody.AddForce. Note that the first parameter is a vector along which the force is to be applied. This force will be applied at the object's center of gravity - it won't start spinning, just moving in the indicated direction. To apply a force that is offset from the center of gravity, see Rigidbody.AddForceAtPosition. This will move and spin your object. The "position" parameter in this case might be the point on the "force line" that is closest to your object, but you can probably get away with using other positions, for example, if the points defining your "force path" are close together, you might be able to use the nearest one. To get the direction to apply the force, subtract the first point (A) (of the force line segment) from the next point along the path (B). This gives you a vector that represents the direction from point A to point B. more ▼ answered Nov 19 '09 at 02:36 AM Bampf 5k ● 8 ● 19 ● 49 Nailed it! Subtracting a from b seems to do the trick! Thanks! Nov 21 '09 at 11:49 PM Goody! add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

### Follow this question

By Email:

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

Topics:

x5053
x1864
x8

asked: Nov 18 '09 at 03:20 AM

Seen: 1607 times

Last Updated: Nov 18 '09 at 02:14 PM