I have a CFrame, represented by

local camera = workspace.CurrentCamera
local camlookvector = camera.CFrame.LookVector

and I have a script that adds a shift lock to my tool when I equip it. It adds an offset to the camera. This is what it looks like:


--Local script in StarterPlayerCharacter
local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
---------------------------------------------------------
local rotation = Instance.new("BodyGyro") --Create a new body gyro.
rotation.P = 1000000 --Increase the power
rotation.Parent = hum.RootPart --Parent it to the HumanoidRootPart
---------------------------------------------------------
local conn -- connection variable
function shiftLock(active) --Toggle shift.lock function
	if active then
		hum.CameraOffset = Vector3.new(1,0.5,0) -- I assume this is about the right camera offset.
		---------------------------------------------------------
		rotation.MaxTorque = Vector3.new(0, math.huge, 0) --Max the power on the Y axis
		---------------------------------------------------------
		conn = game:GetService("RunService").RenderStepped:Connect(function()
			rotation.CFrame = mouse.Origin
			game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
		end) --Set the mouse to center every frame.
	else
		hum.CameraOffset = Vector3.new(0,0,0) --Move the camera back to normal.
		---------------------------------------------------------
		rotation.MaxTorque = Vector3.new(0, 0, 0) --Clear the torque on the HumanoidRootPart
		---------------------------------------------------------
		if conn then conn:Disconnect() end -- Allow mouse to move freely.
	end
end
--shiftLock(true) -- Enable shift lock
--print("Shift lock turned on!")
--[[
shiftLock(false) --Toggle off shift Lock
]]

TL:DR: How can I offset the camera's lookvector by Vector3.new(1,0.5,0)?

2 comments

0

cant you just add the vectors together like: local pos = camera.CFrame.LookVector + Vector3.new(1,0.5,0)

0

I'd do that, but when I do add them it shoots in a very weird way, not as expected