Aiming problem

Im trying to add aiming and Ive encountered a few problems

heres the code so far

void Aim()
    {
	if(Input.GetMouseButtonDown(1))
	{
	    fpsCam.fieldOfView = 55f;
	    playerLook.mouseSensitivity = 50f;
	    rifle.position = rifleAimPos.position;

	    Debug.Log("Pistol is moving position");
 	    pistolHolder.position = pistolAimPos.position;
	    Debug.Log("Pistol has moved");
	}
	else if(Input.GetMouseButtonUp(1))
	{
	    fpsCam.fieldOfView = 70f;
	    playerLook.mouseSensitivity = 100f;
	    rifle.position = rifleStore.position;
	    pistolHolder.position = pistolHolderStore.position;
	}
    }

when i use this code, the rifle moves when you aim but the pistol never moves, it only changes the fov of the camera.

also, im trying to use lerp to smooth the transition but it wont work. it only moves on the z axis. ive made sure to set the pistol aim position to something else but it still wont move.

can anyone help me?

how do i lerp with positions

Make sure the behaviour to change the position is same with rifle.
Try to change this :

pistolHolder.position = pistolAimPos.position;    

to :

pistolHolder.position = rifleAimPos.position;

if it can, then your set of pistolAimPos.position doesn’t work properly, try to look over there


For Lerp do it on set of “pistolAimPos.position”, change the it with :

float SpeedMove = 2.5f;
position = Vector3.Lerp(position, finalPosition, SpeedMove * Time.deltaTime);

Hope it help.

ok idk how this worked but if i put the pistol instead of the pistolholder in the pistolholder slot, it worked, POG