Character is the parent object and has camera object as its child object (FPS type).
Camera object has a script which 'throws' raycast to detect objects in front of it.
Camera object has a child object 'Crosshair', which has a script 'ShowCrosshair' attatched to it.
Expected behaviour should've been: I move the mouse up and down, camera rotates around an axis and along with it the crosshair object moves smoothly remaining at the center of the screen.
But, whenever I move the mouse up/down, crosshair moves faster than the camera can rotate and goes out of sight.
Here's my code for Camera Rotate:
//vertical is globaly defined and transform is for the current gameObject i.e
vertical -= speedV * Input.GetAxis("Mouse Y");
vertical = Mathf.Clamp(vertical, -50, 70);
transform.localRotation = Quaternion.Euler(new Vector3(vertical, 0.0f, 0.0f));
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
150 People are following this question.
I cannot move my camera in the Game mode
Roll a ball camera rotation on Q and E
C# Smooth Follow Space Ship
When attaching my custom camera script camera shakes when player starts to move fast.