Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Do You Use Vector3 Relative To An Object's Bearings?

Asked by 10 years ago

To elaborate, how exactly do you get a Vector3 to point to a location, given the object and the target point? I'd suspect there's going to be some maths involved in getting the angle of the object and propelling the object. AS A SIDE QUESTION: How do you use the Velocity property of a part to shoot it around? I know it works on player torsos, but apparently not on parts.

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

Not much math to it.

The "direction" of a vector is usually defined as the unit (length 1 version pointing same way) of a vector. And the displacement from from to targetis just target - from, so the direction is (target - from).unit.


Velocity should work fine on a part to make it move. If you want to it to continue being propelled in a direction, though, you should use a BodyVelocity object. If you just want to hurl it in a direction (and want it to move like a projectile) then you can just set the velocity.

0
Thanks, great explanation. SquirreIOnToast 309 — 10y
0
I've been experimenting with the Velocity property, it appears to work pretty well if in a Touched function, however just setting it appears to fail. SquirreIOnToast 309 — 10y
Ad

Answer this question