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

How to move diagonally with BodyVelocity * Camera LookVector/RightVector?

Asked by
NordicM 77
4 years ago

I'm making a game where you are a ball that can move. (Like Super Blocky Ball without the player inside of the ball) I can't figure out how to move it diagonally. I am using UiService.InputBegan to find out which keys the player is pressing. I'm making the ball move by which combination of keys they are pressing like... (AWD) is forward, (WSD) is right, (AD) is nothing and (A) is left... (Hope you understand...) This is how I am moving it.

local speed = 10

BodyVelocity.Velocity = Vector3.new(speed, 0, speed) * Camera.CFrame.LookVector

If you want me to post my hole script, tell me in the comments!

0
Is the camera already offsetted from the ball? marine5575 359 — 4y
0
Is the camera already offsetted from the ball? marine5575 359 — 4y
0
ops. sorry if there is 2 marine5575 359 — 4y
0
Kinda? I made the ball become the CameraSubject. (I have a game where it is offsetted, but I'm trying to make it so the camera works like a player camera) NordicM 77 — 4y

1 answer

Log in to vote
0
Answered by
NordicM 77
4 years ago

I found out how to do it! You just have to add up the lookVector and the rightVector

if A and S then
    BodyVelocity.Velocity = (camera.CFrame.RightVector*-speed)+(camera.CFrame.LookVector*-speed)
end
Ad

Answer this question