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

How to keep body velocity at maximum speed?

Asked by 9 years ago

So here is the thing, I have a player controlled marble that has a BodyVelocity object inside it, the BodyVelocity is set to the current camera's lookvector and then multiplied by a few multipliers to increase the speed. But the problem is that the ball only goes full speed when the camera is pointed straight ahead, if it is angled down at the ground at all it slows down, I don't want that. This happens because the Y axis of the lookVector is taking some of the power Instead of just the X and Z axis, but the ball can't move on the Y axis. I would like to find a way for all of the power to go to the X and Z axis so it is at full speed all the time. Here is the code:

game.Workspace.Ball.BodyVelocity.velocity = game.Workspace.Ball.BodyVelocity.velocity:Lerp((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * Vector3.new(100,0,100)* game.Workspace.Ball.Multiplier.Value * game.Workspace.Ball.MultiplierTwo.Value),0.1)

The above is all one line

Answer this question