#(First Person) Player rotates on it's own in a jitter manner, in turn rotating my camera.

1 messages · Page 1 of 1 (latest)

potent ravine
#

When I jump on uneven terrain, say a box or slope, my character starts to rotate very jitterly and in turn rotates my camera as well. I believe I'm not doing a good job at treating the rigidbody physics.

https://paste.mod.gg/tbbubsppjsva/0

full silo
#

!code
also jittery camera usually means you are either updating your camera too early, on a different timestep than the object it is following is being updated on, or you are breaking rigidbody interpolation by modifying the transform in some way rather than performing all move/rotation operations on the rigidbody

astral gobletBOT
potent ravine
runic saffron
#

you can lock the rotation

potent ravine
full silo
runic saffron
full silo
potent ravine
#

Also I'm expermenting with Collision Detection it was on Discrete prior

potent ravine
#

This is my camera movement script

runic saffron
#

why smoothdeltatime?

full silo
#

is lookInput mouse input or controller input? because if it is mouse input you should not be mulitplying it by deltaTime as it would already be a delta. but you should also be calling MoveRotation on the rigidbody in FixedUpdate not Update/LateUpdate

potent ravine
runic saffron
#

yeah but it will slug your mouse movement

#

stuttering etc for camera movement, I would not do that.

#

you gotta slerp it.

potent ravine
#

I see

#

Noted!

runic saffron
#

delta time = immediate
fixed delta = physics
smooth = background animations and such. fluff.

#

@potent ravine try this?

    CameraRoot.position = Vector3.Slerp(CameraRoot.position, targetPosition, Time.deltaTime * 20f);```\
potent ravine
runic saffron
# potent ravine Where would I put this in the script?

ivate void CamMovements()
{
Vector2 lookInput = _inputManager.Look;

if (lookInput.sqrMagnitude < 0.001f) return;

float mouseX = lookInput.x * MouseSensitivity * Time.smoothDeltaTime;
float mouseY = lookInput.y * MouseSensitivity * Time.smoothDeltaTime;

// Rotate player (or CameraRoot) around Y (yaw)
Quaternion yawRotation = Quaternion.Euler(0f, mouseX, 0f);
_playerRigidbody.MoveRotation(_playerRigidbody.rotation * yawRotation);

// Accumulate pitch and clamp it
_xRotation -= mouseY;
_xRotation = Mathf.Clamp(_xRotation, UpperLimit, BottomLimit);

// Apply pitch to Camera local rotation
Camera.localRotation = Quaternion.Euler(_xRotation, 0f, 0f);

// Ensure CameraRoot position follows player (if needed)

Vector3 targetPosition = _playerRigidbody.position;
CameraRoot.position = Vector3.Slerp(CameraRoot.position, targetPosition, Time.deltaTime * 20f);

potent ravine
#

Do you see how the camera is like jittering?

#

I'm not moving the mouse when that happens

runic saffron
#

ah

#

now this makes more sense. you just need to seperate the two

potent ravine
#

What do you mean seperate the two?

runic saffron
# potent ravine What do you mean seperate the two?

PlayerController (Empty GameObject - No Physics)
├── PlayerBody (Rigidbody + Collider + Movement Script)
│ └── PlayerModel
└── CameraRig (Camera Controller Script)
└── MainCamera

#

right now you basically have a parent object that has a rb for the camera, that aint bueno.

and that would mean the slerp would actually be nice.

#

when you seperate the two.

but you gotta redo some stuff for the camera for sure.

potent ravine
#

So like this?

#

Also ty for trying to help me , I rlly appreciate it

runic saffron
#

yeah looks good.

#

no components on the playercontroller?

potent ravine
runic saffron
#

so now it works right

potent ravine
#

The camera is in the floor and not following, I'm tryna configure it