FPS Character Controller HELP with head bob and camera!

Ok, I am quite new to Unity and coding with c Sharp, what I would like to know, is there a way to make it so my gun doesn’t have to be attached to the camera so I can still see the head bob if that makes any sense? I am meaning, my gun isn’t attached to the camera so now I have a really nice looking head bob so it creates the effect of a head bob. However now when I look up, the gun does not rotate upwards, however it still does when you move the mouse along.
Help would be much appreciated!
I tried making a script so that the gun would follow the cameras Y rotation, however this didn’t work well at all, and I am sure there will be a better way I just do not know it yet, I have spend the past 2 hours trying to figure it out :C to no luck…
Many thanks!

you could make the gun stay in the same spot using camera to screen point.
This will be some learning but its possible

@AngryKiwiArts
Thanks for your reply, though like I said I am quite new to Unity and unfortunately didn’t really understand what you said :smiley: (My bad…) I have taken a screenshot of my higher-achy and player, perhaps this will help. n

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class headBob : MonoBehaviour
{
// Made by Evan Reid

[Header("Set the dampening to a value to a number between 0 and 1. 0.2 is my prefered value")]

public float dampening = 0.2f;

void Update()
{
    transform.localPosition = new Vector3(0,(float)Mathf.Sin(transform.parent.position.x + transform.parent.position.z),0) * dampening;
}

}