Search Unity

FPS Gun Movement/Rotation (Tiny Problem)

Discussion in 'Physics' started by gh7, Dec 10, 2014.

  1. gh7

    gh7

    Joined:
    Apr 15, 2014
    Posts:
    10
    Screenshot (2).png Screenshot (1).png So, as you can probably tell, my gun seems to be rotating locally. The guns movement is dependent upon my mouse look script, and a gun script that smooths the movement to the cameras rotation. I'm trying to achieve a COD/BF4 style, where the gun rotates with the camera "Globally". Any help would be greatly appreciated. Thank you for your time.

    P.S. Sorry if this is the wrong place to post this, I wasn't sure since it's kind of specific and I thought it Physics vaguely covers the rotation and positioning of objects.
     
  2. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Posts:
    969
    Your pivot is probably off, but if you're going for a CoD style then place the gun as a child of the camera, and problem solved.
     
  3. gh7

    gh7

    Joined:
    Apr 15, 2014
    Posts:
    10
    Not quite CoD style. Just similar. All I want is where the gun stays straight in line with the camera on the x-axis, so when you look whilst aiming, it stays in line with the camera. But thanks for the advice, I may take a different approach, but I'll keep working on this.

    Is there a way to do this through scripting? I want to avoid making the gun a child of the camera. It creates issues in the development streamline.