- Home /
Gun not rotating with the camera?
So I watched a tutorial series on an FPS and I want to remake the gun following the camera system because it is really jittery when I look around. I am trying to see if using Slerp(); instead of SmoothDamp; will help but for some reason my gun is not rotating at all when I do. Help!
rotationTarget = Quaternion.Slerp(rotationTarget, cameraObject.transform.rotation, Time.deltaTime * rotationSpeed);
transform.rotation = Quaternion.Euler(rotationTarget.x * -1, rotationTarget.y - 180, 0);
Answer by Kleptomaniac · Mar 09, 2013 at 10:43 PM
Hey there,
You're going about this the wrong way. Instead of hard-coding your gun to follow the rotation of the camera, all you need to do is parent you gun GameObject to your camera. You can do this by dragging you gun GameObject on top of the camera object in the Hierarchy.
By parenting it, you gun's rotation values will now be made relative to the camera's rotation values, and it will achieve what you're going for. :)
Hope that helps,
Klep