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

How Can I Make This Object Turn in Circles Rather Than In Place?

Asked by
8391ice 91
7 years ago

I have a game that involves remote-controlling vehicles with the WASD keys. There are two NumberValues, Velocity and Turn, in the tank that are changed via a script that uses the player's input. I've already made and perfected the script that changes these values; the problem is the script below, in the tank, which updates its velocity and AngularVelocity based on the values.

while wait(.03) do
    script.Parent.Turn.AngularVelocity = Vector3.new(0, script.Parent.Parent.Turn.Value, 0)
    script.Parent.Velocity = Vector3.new(script.Parent.Parent.Velocity.Value, 0, 0)
end

When I tested it out, the vehicles moved forward and backward, but when I tried to move left or right, they only turned in place; in other words, the vehicle will always move forward and backward on the same X plane. It doesn't change the direction it moves forward in based on its rotation. So how can I accomplish that? I want my vehicles to move forward and backward in the direction that they are facing.

Any and all help is highly appreciated!

0
Research world coordinates versus object coordinates. GoldenPhysics 474 — 7y

Answer this question