fps camera/gun rotation

hey! does anyone know how to make the camera move along with the gun? i was reserching and i found out how to get the gun to rotate wich is awsome. sept for the fact that the camera stays in one position and you get to see the caracter twist and turn while your in first person shooter mode…kinda messes the whole game up. so what i am trying to atchive is sorta like how call of duty makes their cameras move with their guns or weapons u know?
this would be a major help if someone could help me out. kinda gets frustrating after a while :o

(in the higharchy) Just drag the gun to where it should say Main Camera, or Camera. Then the gun should follow the camera. Just make sure the Gun is Under the camera in the higharchy.

Here is step by step instructions…

1: Select your gun with your mouse in the sidebar, not in the scene.

2: Drag it to your camera that the player should normally see in the sidebar.

3: This should work, if not just respond and ill try to help. Make sure you test it by clicking play. I may have misunderstood your question.

alt text

This is a screenshot I quickly took of what it should “sort of” look like.

Also, you sound a bit like a beginner, if your not, my mistake, but try reading Unity Essentials by William Goldstone, thats how I got started, its a textbook, but its interesting. Check it out. A lot of people come on here, thinking you can just make a game like call of duty. It takes years and years of practice to make a game like angry birds on your own, Call of duty takes hundreds of people… Again, for all I know your way better then me at this. Just making sure…

*Good Luck on whatever game your making, and you know, you could always give away a few beta copies to Unity people before your done hint hint.

**Just letting you know, If you Liked my answer, please click the checkbox, if not, I’ll work with you to try to solve it. ** Generally I wouldn’t tell you but you seem to be new around here. Again, just assumptions, you could be a founder of Naughty Dog for all I know.

I see you have a 0% accept rate, please accept an answer when asking a question, its not only rude not to, but its a general concencious around here that you have to eventually. In respect for the other people, please accept answers from now on, and if you can spare a minute, go back and accept the peoples answers from your other questions.

alt text If its green, it means you have accepted it.

Thanks,

P.S. Just saying, I answered before the other guy with the same answer… haha

That’s an easy question to answer,make the gun a Child object of the Camera, NOT THE FPS CONTROLLER, also if you want the gun to sway a little, Here is the Script:`

public var MoveAmount : float = 1;

public var MoveSpeed : float = 2;

public var GUN: GameObject;

public var MoveOnX : float;

public var MoveOnY : float;
  
public var DefaultPos : Vector3;

public var NewGunPos : Vector3;

function Start(){

DefaultPos = transform.localPosition;

}

function Update () {

MoveOnX = Input.GetAxis( "Mouse X" ) *Time.deltaTime * MoveAmount;

MoveOnY = Input.GetAxis( "Mouse Y" ) *Time.deltaTime * MoveAmount;

NewGunPos = new Vector3 ( DefaultPos.x+ MoveOnX, DefaultPos.y+ MoveOnY, DefaultPos.z);

GUN.transform.localPosition = Vector3.Lerp(GUN.transform.localPosition, NewGunPos , MoveSpeed * Time.deltaTime);

}`

You could use the fps pill and change the mesh to the one u got, Hope that fixes your prob, BTW you should only mark answers as correct if they are correct, the question you marked is not correct (from what your saying) so I suggest you press the tick again to unmark the question. Hope this fixes your prob :slight_smile: