- Home /
Question by
abdelrahmanyoussry509 · Apr 19, 2020 at 12:12 PM ·
camerapositioncamera followgun position
camera follow the gun!
i cant find a way for the gun to follow the camera up and down it does a very weird up and down movement like its on an arc or something here is the code (sorry i can not explain it very well as i am a complete beginner)
// Update is called once per frame
void Update()
{
float MouseX = Input.GetAxis("Mouse X") * MouseSenstivity * Time.deltaTime;
float MouseY = Input.GetAxis("Mouse Y") * MouseSenstivity * Time.deltaTime;
PlayerBody.Rotate(Vector3.up * MouseX);
rotationY = rotationY - MouseY;
rotationY = Mathf.Clamp(rotationY, -90f, 90f);
transform.localRotation = Quaternion.Euler(rotationY, 0f, 0f);
weapon.localRotation = Quaternion.Euler(rotationY, 0f, 0f);
}
}
Comment