Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Vector3.y only, without x and z?

engine.RotVelocity.Vector3.y = (vehicleSeat.Steer*steeringSpeed)

I know, the line above is totally broken. How do I move Vector3.y only without moving x and z?

1 comment

0

It is the same as what you did, I believe, but instead of using "RotVelocity.Vector3.y" use "RotVelocity.y"

1 answer

A Vector3 doesn't have a Vector3 property, so obviously your line is wrong.

It does have a y property, though, so it might look like this:

engine.RotVelocity.y = vehicleSeat.Steer * steeringSpeed;

However, we can see here that all of a Vector3's properties are read only.

We have to set the Vector3 value as a whole.


If you want the X and Z values to be zero, it's easy to just construct a new one:

engine.RotVelocity = Vector3.new( 0, vehicleSeat.Steer * steeringSpeed , 0);

If you want this to not affect the X, and Y values, we can either do a little amount of Vector math, or just read the coordinates ourselfs:

local previous = engine.RotVelocity.y;

local withoutY = previous * Vector3.new(1, 0, 1);
-- Does component-wise multiplication
local Y = Vector3.new( 0, vehicleSeat.Steer * steeringSpeed , 0);
engine.RotVelocity = withoutY + Y;

or

local previous = engine.RotVelocity;
engine.RotVelocity = Vecto3.new( previous.x, vehicleSeat.Steer * steeringSpeed, previous.z );

This discussion is preserved as it was. New answers, comments, and votes are closed.