#VR camera help

59 messages · Page 1 of 1 (latest)

rich lily
#

Im trying to create a vr game, and ive made it pretty far, i just was wondering how i would be able to rotate the camera based on the x position of the joystick? ive looked at quite a few forums but nothing quite worked

rich lily
#

im having a little bit of trouble, how would i be able to do that but add it on to a cframe.angles?

#

like a new one

hybrid emberBOT
#

studio** You are now Level 6! **studio

rich lily
#

wel;l my code is like this

#

Run.RenderStepped:Connect(function()
Cam.HeadLocked = false
Cam.CameraType = Enum.CameraType.Scriptable
local headcframe = VRS:GetUserCFrame(Enum.UserCFrame.Head)
local rotatedcframe = CFrame.Angles(0,math.rad(turnpos),0)*CFrame.Angles(headcframe:ToEulerAnglesXYZ())*headcframe.
Cam.CFrame = CFrame.new(0,6,0) * CFrame.new(headcframe.Position) * (CFrame.Angles(headcframe:ToEulerAnglesXYZ()))
Cam.CFrame *= Cam.CFrame:ToWorldSpace(rotatedcframe)
end)

#

im trying to make the camera spin with the joystick

#

its not workign at all tho

#

no, it just isnt spinning at all and the camera movements are super dramatic-is

#

like i move my head down and up and it would be doing like 5 backflips

#

0-1

#

wait no

#

-1 to 1

#

UIS.InputChanged:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Thumbstick2 then

        turnpos = input.Position.X
    end
end)
Run.RenderStepped:Connect(function()
    Cam.HeadLocked = false
    Cam.CameraType = Enum.CameraType.Scriptable
    local headcframe = VRS:GetUserCFrame(Enum.UserCFrame.Head)
    local rotatedcframe = CFrame.Angles(0,math.rad(turnpos),0)*CFrame.Angles(headcframe:ToEulerAnglesXYZ())*headcframe
    Cam.CFrame = CFrame.new(0,6,0) * CFrame.new(headcframe.Position) * rotatedcframe
    Cam.CFrame *= Cam.CFrame:ToWorldSpace(rotatedcframe)
end)
#

i tried that, but it is reseting the camera every renderstepped

#

yea thats just bc i was trying to fix it

#

or make it work

#

and i didnt get rid of those value s yet

#

?

#

yea

#

cframe is weirdly confusing

#

well then the whole thing wouldnt work

#

wait nvm

#

sorry

#

spoke to soon

#

lmao

#

well i also need it to do the rotation and position of the head irl

#

and thats where the problem is

#

o ok

#

yes

#

thats not the problem, i just need an offset so then when it does the calculations of where to do the rotation and position it rotates it based on how much you put the joystick to the left or right

#

nope

#

how would i get an offset, so that only the rotation is effected by it

#

wait lemme try something

hybrid emberBOT
#

studio** You are now Level 9! **studio

rich lily
#

oh

#

yea but i was asking how would i just affect the rotation

#

not right now, but im trying to make it do that

#

ok

#

o yea

#

wait

#

it works

#

kinda

#

yea i tried that

#

it works

#

but one problem

#

its like only rotating on the local y axis

#

like if i have my head slightly down and i rotate it 180 degrees it will be slightly up

#

yea

#

i think

#

im pretty sure

#

o ok

#

nope doesnt work

#

Run.RenderStepped:Connect(function()
Cam.HeadLocked = false
Cam.CameraType = Enum.CameraType.Scriptable
local headcframe = VRS:GetUserCFrame(Enum.UserCFrame.Head)
local rotatedcframe = CFrame.Angles(0,math.rad(offset),0)
Cam.CFrame = CFrame.new(0,6,0) * CFrame.new(headcframe.Position)
Cam.CFrame *= Cam.CFrame:ToWorldSpace(CFrame.Angles(headcframe:ToEulerAnglesXYZ())*rotatedcframe)
end)

#

alr ima try this and then im done

#

nope doesnt work

#

im gonna go kms now

#

gn