Hello, I made a crouch script and tried to change the camera position using CameraOffset, but the camera goes down for a moment and comes back, I thought it was because of lerp, but after trying different ways to change CameraOffset, nothing helped me.
ContexAction:BindAction("Crouch",function(name,state,obj)
if player.Character:FindFirstChild("Humanoid") then
if state == Enum.UserInputState.Begin and not script.Sprinting.Value then
local vector = Vector3.new(0,-1.5,0)
script.Crouching.Value = true
playanim:Play()
player.Character.Humanoid.WalkSpeed = 8
hum.CameraOffset = hum.CameraOffset:lerp(vector, 0.25)
else
hum.CameraOffset = hum.CameraOffset * 0.75
script.Sprinting.Value = false
script.Crouching.Value = false
playanim:Stop()
player.Character.Humanoid.WalkSpeed = 12
end
end
end,true,Enum.KeyCode.LeftControl,Enum.KeyCode.C)
Can you explain in more detail what is actually happening with the script, sounds like the camera does have an offset. Can you also explain what you expect to happen?
:lerp doesn’t do any sort of animation if that’s what you are hoping for, it’s a mathematic function for finding an in-between position of two values, where the second argument is how much from A to B.
I expect the camera to shift down, it shifts literally for a second and then comes back. I tried to do this without lerp, hum.CameraOffset = Vector3.new(0,-1,0) this is don’t even work
Do you continue to crouch (i.e. walk slowly)? Is it just the offset that isn’t working? Maybe you need to change th else to if it’s firing for Changed or Cancel states.
Ooh wait, it seems to me that this is because of my script for camera movement, because it checks whether the player is moving or not and if not then Cameraoffset * 75