I have a problem with making a first person shooter

Ok so this is my first question I’ve posted. I’m trying to do a quick build of a first person shooter to get a functioning product done as I haven’t really finished anything. So I’m not focussing too much on quality as that’s what gets me caught up in production.

Anyway my problem:

So it’s sort of two part. My first problem, which won’t exactly be a problem later, but it could be: I made guns out of cubes to start coding, and so I didn’t have to sit and code a holding block I just made it a child of my camera, and positioned it at the hold position. This is working fine but for some reason when I look up and down the gun warps weirdly. I’ll try to attach some screenshots.

The next problem is I’ve written a block of code for switching guns. It works perfect for certain guns, but once I get to the first gun I’ve made it runs the DropGun() function on the gun I’m trying to pick up and keeps the one I already have. Also when I continuously try to pick up the gun, it warps them also. I’ve also found it’s when I have my camera faced down where the gun I’m holding is warped. Any help would be greatly appreciated. I’m not a beginner to coding or using unity (however I wouldn’t say I’m a strong coder), but this is a problem I can’t figure out. This will help me learn a bunch.

here are the picking up and dropping functions Let me know if you need to see any other code:

void Pickup()
{
if (pControl.currentGun != null)
{
Firearm arm;
arm = pControl.currentGun.GetComponent();
arm.DropGun();
}

	Debug.Log("I'm getting picked up");
	gameObject.transform.parent = cam;
	body.isKinematic = true;
	body.useGravity = false;
	collider.enabled = false;
	transform.localPosition = holdPosition;
	transform.localRotation = Quaternion.identity;
	isHeld = true;
	pControl.currentGun = gameObject;
}

public void DropGun()
{
	gameObject.transform.parent = null;
	body.isKinematic = false;
	body.useGravity = true;
	collider.enabled = true;
	body.AddForce(Player.transform.forward * throwPower);
	isHeld = false;
}

Just an Update: I figured out the problem with the warping guns. I had had the camera as a child of my capsule, and I scaled it up (I’m using each unit as 1meter) which also scaled the camera up in the y axis. This caused some unwanted effects. So incase anyone else has experienced the same problem.

Still working on my weapon switch script. I’m sure I’ll figure it out eventually.

void Pickup() { if (pControl.currentGun != null) { Firearm arm; arm = pControl.currentGun.GetComponent(); arm.DropGun(); }

I think when you run Pickup() you run DropGun() at the same time so the gun you try to pick up immediately gets dropped, I can’t be sure unless I know what the script is attached to. I am not sure what pControl is but you could try setting pControl.currentGun = null; then set pControl.currentGun equal to the weapon you are trying to pick up.

Make sure the two guns have different names other than both being called gameObject I say this because I don’t see gameObject being set to the guns (assuming that’s a gun).

I hope I am making sense I have not answered many questions, try running DropGun() first then PickupGun() to make sure you are setting the gameObjects parent to null.

Just a few things to try, Hope this helped.