i was making my game but the code i permanently borrowed for third person camera make my whole screen shake
Paste the code as we cannot help you, also what do you mean:
That sounds a bit strange
i copied a code o youtuber gave from a tutorial, it was for comedic effect also the script;
`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveAroundObject : MonoBehaviour
{
[SerializeField]
private float _mouseSensitivity = 3.0f;
private float _rotationY;
private float _rotationX;
[SerializeField]
private Transform _target;
[SerializeField]
private float _distanceFromTarget = 3.0f;
private Vector3 _currentRotation;
private Vector3 _smoothVelocity = Vector3.zero;
[SerializeField]
private float _smoothTime = 0.2f;
[SerializeField]
private Vector2 _rotationXMinMax = new Vector2(-40, 40);
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * _mouseSensitivity;
float mouseY = Input.GetAxis("Mouse Y") * _mouseSensitivity;
_rotationY += mouseX;
_rotationX += mouseY;
// Apply clamping for x rotation
_rotationX = Mathf.Clamp(_rotationX, _rotationXMinMax.x, _rotationXMinMax.y);
Vector3 nextRotation = new Vector3(_rotationX, _rotationY);
// Apply damping between rotation changes
_currentRotation = Vector3.SmoothDamp(_currentRotation, nextRotation, ref _smoothVelocity, _smoothTime);
transform.localEulerAngles = _currentRotation;
// Substract forward vector of the GameObject to point its forward vector to the target
transform.position = _target.position - transform.forward * _distanceFromTarget;
}
}`
Hi @Zelektro,
Did you try to change value of _mouseSensitivity in your pernamently borrowed script?
Ä° dont think its because of mouse sensivity even i dont know anything aboyt C# but even not moving the mouse or just moving with WASD (no cursor) i dont exactly remember but it was still shaking i think
@Zelektro so maybe start by lowering it, and checking out result… maybe for some reason person which write your script incuded it on top of inspector… and exposed private property…
Amount of shake depends, from mouse input,.and is damped in time. You also had exposed private varaible which will determine how long efect occure.
With code like this almost no C knowlage is neeeded: variables had nice names, and there are comments…
Hope you will solve your issue by playing with this exposed variables.
it had absolute zero with the mouse sensivity.
I Don’t see you updating the _target or _distanceFromTarget anywhere in that code, so I don’t see how setting the transform.position is going to work properly.
Maybe some part of the code is missing?
Change the Update to LateUpdate.
oh my god thank you