Relative forward

I’ve been struggling with this for a while now. So basically i have a lego-like character that has a rotatable torso (which is rotated my mouse movement) and a gun in his hands (he is holding it horizontal, off centered). What I want to achieve is to set the torso forward to the gun’s barrel forward, so when the torso is perfectly aligned forward, the barrel will be perfectly aligned. And as a result when i move the torso the gun’s barrel will be on the desired direction of shooting…

Looking at your screenshots, I think you could just put the torso as the child of a new GameObject. and add some y rotation on the torso so the gun is pointing forward. Then apply your mouse rotation to the new GameObject instead.

like Buckslice said you can make the gun barrel the child of the torso. If thats not an option you can easily get the torso’s forward direction if you have a reference to its transform with a call like torsoTransform.forward and then use that vector to set the position/orientation of the guns barrel.

@TSI25 @Buckslice
Well the gun is a child of the right hand, and is working well with character animations like shooting and reloading so making it a child of a torso wouldn’t be the best solution…
Here are some screenshots,
Current situation(left) and desired result (right):

I tried playing around with the forward axes…
When doing this:
weapon.forward = torso.forward;
It aligns the weapon with the torso, without moving the torso which is the opposite of what I want but close, so I figured out that the following would work:
torso.foward = weapon.forward;

But this is what I get from the code above: