So It’s pretty simple to go forward, backward, right, left with body velocity and such Testing Facility 2.0 - Roblox Studio 2021-05-26 20-22-58
but I have no idea how to make myself move forward diagonally to the right/left same thing in the opposite direction. How would I go about it?
if Type == "Forward" then -- this is to go forward
local Forward = Instance.new("Animation")
Forward.AnimationId = "rbxassetid://6868578043"
local anim = Hum:LoadAnimation(Forward)
anim:Play()
anim:AdjustSpeed(1.3)
MovementVel.Velocity = HumRT.CFrame.LookVector * Speed
endit(MovementVel,PrevMaxForce,PrevVelocity,.3)
Roll:FireAllClients("Forward")
elseif Type == "DiagRight" then -- this is the code i started for going forward diagonally to the right its the same as forward as idk wat to do
local Forward = Instance.new("Animation")
Forward.AnimationId = "rbxassetid://6868578043"
local anim = Hum:LoadAnimation(Forward)
anim:Play()
anim:AdjustSpeed(1.3)
MovementVel.Velocity = HumRT.CFrame.LookVector * Speed
endit(MovementVel,PrevMaxForce,PrevVelocity,.3)
end
To go diagonal you need to manipulate the LookVector value to the sides, you can accomplish this with the code below, just manipulate the X and Z values until it goes where you’d like
local X = 0
local Z = 0
local GoalVelocity = ((HumRT.CFrame.LookVector * Speed) * CFrame.new(X, 0, Z))
ok i did wat you said and kept the multiplication symbol but then it didnt go diagnol instead just shot me forward fast so i changed it to plus symbol now it goes diagnolly problem is its not based on the way im facing more so the world COGmK8wnza.mp4
local X = 30
local Z = 30
local GoalVelocity = ((HumRT.CFrame.LookVector * Speed) + Vector3.new(X, 0, Z))
local Forward = Instance.new("Animation")
Forward.AnimationId = "rbxassetid://6868578043"
local anim = Hum:LoadAnimation(Forward)
anim:Play()
anim:AdjustSpeed(1.3)
MovementVel.Velocity = GoalVelocity
endit(MovementVel,PrevMaxForce,PrevVelocity,.3)
Lol oh yeah I forgot its a vector so you add, basically you just visualize the world as a graph so you just add on the X and Z axis’ to manipulate where you want it to end up
is there a way to detect and calculate my position to the world to determine how much i may need to add/subtract? cuz like if im going one way ill go diagonally right but if i turn around and face a different direction ill go left