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

I need some assistance with understanding velocity?

Asked by 10 years ago

I've known how to make things go forwards with velocity since I started scripting...

object.Velocity = object.CFrame.lookVector *1234--random number which would move real fast

Is their any other way to do this to the left and right?

1 answer

Log in to vote
0
Answered by
jakedies 315 Trusted Moderation Voter Administrator Community Moderator
10 years ago

Sure, the lookVector returns a direction facing the -z axis of the CFrame. You can use the components to return the other directional vectors (which may be the most efficient) or you can do this:

local objectCF = object.CFrame;
local rotation = objectCF - objectCF.p; -- We remove (subtract) position from the CFrame
local left = rotation * Vector3.new(-1, 0, 0); -- We multiply it by a Vector3 with -1 on the x-axis (which is left.)
object.Velocity = left * 1234;
0
using rotation * Vector3.new(1, 0, 0) would be right? xolbStudios 127 — 10y
0
Yes, or you can do left * -1234 jakedies 315 — 10y
0
Thanks xolbStudios 127 — 10y
Ad

Answer this question