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

How can I apply BodyVelocity to an object based on it's local orientation?

Asked by 7 years ago

I need to apply Velocity to a ship based on it's local rotation. My only issue is that the methods that I have tried so far fail in one area: When more then one rotational axis has force applied to it she ship rotates on another axis,

Eg if the X and Y rotational axis both have force applied to them, the Z axis starts rotating as well. Is there any way to fix this?

(if it helps at all I am trying to make a space craft move based on it's rotation applied from a BodyAngularVelocity bodymover)

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago

BodyGyro objects are great for maintaining orientation. Give their CFrame property this constructor:

BodyGyro.CFrame = CFrame.new( [Vector3]Origin, [Vector3]Focus )

As for figuring the direction to apply force, use this formula:

local p = workspace.Part;
local power = 100;

p.BodyVelocity.Velocity = p.CFrame.lookVector * power;
0
So origin should be the base part position, but what should focus be? plasma_node 343 — 7y
0
wherever you want your craft to be looking man Goulstem 8144 — 7y
Ad

Answer this question