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

Why is this script only changing the lookvector by a really, really tiny bit??

Asked by 4 years ago

It only changes it by a tiny bit, like it only adds one ten-thousandth to the axis.

help

local camcenter = workspace.CameraCenter
local ccframe = camcenter.CFrame

local MaxIncrement = 10
local increment =    1

local uis = game:GetService("UserInputService")

uis.InputBegan:connect(function(input)
    print("InputDetected")
    if input.UserInputType == Enum.UserInputType.Keyboard then
        print("KeyboardInputDetected")
        if input.KeyCode == Enum.KeyCode.E or input.KeyCode == Enum.KeyCode.Q then
            print("WUPInputDetected")
            if (ccframe.LookVector + Vector3.new(0, 0, increment)).Z < Vector3.new(0, 0, MaxIncrement).Z then
                print("Changing")
                local newcframe = CFrame.new(Vector3.new(0,0,0), Vector3.new(ccframe.LookVector.X, ccframe.LookVector.Y, ccframe.LookVector.Z + increment)) 
                ccframe = newcframe
                print(ccframe.LookVector.Z)
            end
        end
    end
end)


1 answer

Log in to vote
2
Answered by 4 years ago

LookVectors are unit vectors and are limited between the bounds of -1 to 1 and will never exceed either.

1
To add onto this, it is common to multiply the unit by a number if you want the vector to move more. HappyHammer55555 99 — 4y
Ad

Answer this question