Unity thinks butt of gun is front

**We tried flipping the Z axis and it still doesn’t work properly.

The small gun works as can be seen in the video but the big one is going left when it should go right and vice versa. - YouTube

The old gun worked perfectly. I have tried for hours to get it to work and my artist has sent me various guns to test with different pivot points but none work as the original. The gun is parented to the right hand. Anyone know how to fix this?

OK we can see it’s transform.position = transform.parent.position but position is only one part of the transform. Does the script that attaches your gun to a parent gameObject on the player also set it’s rotation?

transform.rotation = transform.parent.rotation;

put that in Update() on the script attached to your gun and that should fix it then you just need to make sure it points in the right direction, but if your lucky it might br right first time.

Oh and the gun isn’t rotating in either clip, think of it in world space the gun remains pointing to the same place in the world but it looks like it’s rotating because the player moves it’s rotation in world space.


And what happens if you click the mouse when playing the game? Clip of it would be good.

You might get away with dropping the gun on the player but doing that and forcing the gun to look at a certain spot is going to end up with it looking pretty much like you have there.

First things first though let’s work out exactly what’s happening.

After you create the clip of changing the mouse point try commenting out the look at line and see what happens.

If that doesn’t fix the issue try adding the rotation line I suggested on the script attached to the gun.

I understand that you might want it to look directly to the spot but you still need to have some way to make the arm move with it (if the player facing in a reasonable direction). The way you’ve got it setup you could turn round and end up with the gun pointing at the player!

Fairly sure that’s not what you want, but don’t worry with a bit of testing we can fix this.

Oh and I suggested click but I guess you might just have it following the mouse so if that’s the case then show mouse movements in that first clip.


And it would be good to see the script with the look at line as well.

I didn’t know you edited the post. Thanks a lot but I solved it by downgrading back to 4.6.
Do you have an example script for parents games objects such as a gun to the player?

*** Thanks for the script, I’ll check it out tonight. It was unity 4.6.1.