Why my camera trembling when i rotate it?
I'm creating a script to control my camera and my character on a unity scene but when I turn my camera with my mouse, the background tremble. But the more I turn, the more my background tremble.
public Camera FPSCam;
void Update()
{
yaw += speedH * Input.GetAxis("Mouse X");
pitch += speedV * Input.GetAxis("Mouse Y");
transform.eulerAngles = new Vector3(0.0f, yaw, 0.0f);
FPSCam.transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
}
I already tried many thinks to fix my bug like change the Update() by a FixedUpdate() or use a Vector3.smoothDamp() to update the transform.eulerAngles.
You can download build project following this link:
https://drive.google.com/file/d/1KIJMp0Kr_6vsXF7dXn2HUOe33r473zJQ/view?usp=sharing
Thanks for help.
PS: please, excuse my English level, I'm french...
without check all you problem, just try something, just to be sure thats not the error. change Update()
to LateUpdate()
Thanks for your answer, I tried it this morning but the result is the same as I tried to replace Update() by FixedUpdate().
Answer by xxmariofer · Jan 29, 2019 at 09:09 AM
use the update, and rather than changing the rotation, you should be rotating towards the desired rotation.
https://docs.unity3d.com/ScriptReference/Vector3.RotateTowards.html
Your answer
Follow this Question
Related Questions
Boolean variable is never true, even if declared true or ticked in the inspector 1 Answer
RTS camera Controles 0 Answers
I need help witha bug,Glitch While looking up 0 Answers
Render to minimap on command 1 Answer
Third Person Shooter Controller 0 Answers