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

I am very confused, is this an engine bug?

Asked by 2 years ago

Someone explain this please

targetX = 0
while true do
    targetX += 1
    print(CFrame.Angles(math.rad(0), math.rad(0), math.rad(targetX)).LookVector)
    wait()
end

Output is always -0, -0, -1

targetX = 0
while true do
    targetX += 1
    print(CFrame.Angles(math.rad(0), math.rad(targetX), math.rad(0)).LookVector)
    wait(0.1)
end

Outputs are always changing here

targetX = 0
while true do
    targetX += 1
    print(CFrame.Angles(math.rad(targetX), math.rad(0), math.rad(0)).LookVector)
    wait(0.1)
end

Outputs are always changing here too

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
2 years ago

This is not a bug. You are rotating on the same axis that the LookVector points to. The LookVector points to the direction the front of the CFrame is facing. Basically, it tells you where the front of the CFrame is facing and also, the direction the CFrame's Z axis in its local space is facing.

This is best explained with visualization though. Here's a part with a few attachments: one that points in the direction that the axes face (except the front one, since the LookVector points in the -Z direction). Here is the image link which shows each attachment and identifies them

In the following gif, the part gets rotated on the Z axis. Here is the gif

Notice how the front attachment doesn't move, but the others do, because you are rotating on the same axis that the lookvector points to. You also notice that this result is reflected when you rotate on the Z axis and obtain the LookVector of it. This is also true if you were to rotate on other axes and obtain the respective direction vector that the rotation axis points in.

For example, you can apply a rotation on the X axis, then obtain the RightVector and you notice that the result is the same, or when you apply a rotation on the Y axis, then obtain the UpVector and you also notice that the result is the same

Ad

Answer this question