Gameobject shakes while the position/rotation is being changed.

I have a bob script attached to the camera and I also have a gun as the child of the camera. It is set up as when the user hold right mouse button , the camera’s FOV becomes 4.

But then when i move the gun or it moves automatically due to the gunbob script of the camera,it feels like it is going back and forth and literally shakes.

Any way to fix this?

Same Problem

2 Answers

2

The problem here i think is with the parenting of the objects. For examble if you have a scropt for the “Head bob” on the camera, and the gun is a child of the camera the bob script will apply position and rotation not only for the camera, but for the gun as well.
The solution to this would be to set up the two objects as siblings. Parent them independetly to an empty gameobject and apply the script to the camera without having any children.

Are you updating them at different times? I mean, maybe you’re updating one at Update and the other at FixedUpdate?

no it all happens in one Update function