script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
local uis = game:GetService("UserInputService")
local ball = script.Parent:WaitForChild("PlayerSphere")
while true do
wait(0.1)
if uis:IsKeyDown(Enum.KeyCode.W) then
ball.AssemblyAngularVelocity = Vector3.new(-5 , ball.AssemblyAngularVelocity.Y , ball.AssemblyAngularVelocity.Z)
elseif uis:IsKeyDown(Enum.KeyCode.A) then
ball.AssemblyAngularVelocity = Vector3.new(ball.AssemblyAngularVelocity.X , ball.AssemblyAngularVelocity.Y , 5)
elseif uis:IsKeyDown(Enum.KeyCode.D) then
ball.AssemblyAngularVelocity = Vector3.new(ball.AssemblyAngularVelocity.X , ball.AssemblyAngularVelocity.Y , -5)
elseif uis:IsKeyDown(Enum.KeyCode.S) then
ball.AssemblyAngularVelocity = Vector3.new(5 , ball.AssemblyAngularVelocity.Y , ball.AssemblyAngularVelocity.Z)
end
end
How can I make the changes in velocity relative to the camera.
Use the balls CFrame.LookVector to move it forward use negative the balls CFrame.LookVector to move it back (-CFrame.LookVector) use CFrame.RightVector to move it right and use -CFrame.RightVector to move it left. This will only work if the ball not actually rolling and is anchored. So if you have a texture on it that you need to see rolling then instead create a small part, put it in the middle of the ball and use a constraint to hold the ball to the part and use the same thiing I said previosuly but only apply it to the part.
I don’t think I can rely on Up/Look/Right Vectors for situations like when the camere points to the front, so I wanted to see if I could bse the movement from the direction of the camera top to bottom
For example:
In this image, the objective left is at the bottom and the right at the top
Yes but the ball won’t roll if I just change it’s CFrame.
My problem is not with the physics, just with getting the amounts to be relative to the camera
You know how when you turn the camera when playing a game and press W your character moves forward relative to you?
I have the input part down but i’m having trouble with the camera.