Sprint position for gun

Hi, I have a working sprint script that works very well, but I want even better performance by making my guns going into a sprinting position when the shift key is held down. Does anyone know how to to this, because I think it has something with quaternions to do with, but I don’t know anything about quaternions. Anyone?

First you need to find your gun transform. So I’m assuming its in your hierarchy. So this is how you’d grab it.

 public void sprint()
 {
   Tranform gunTransform = transform.Find("Gun").transform;
   gunTransform.Rotate( new Vector3(PitchDelta,YawDelta,RollDelta))
 
  //other sprint related stuff
 }

pitch/yaw/roll delta are floats of how much you want to rotate. I’d save the current rotation as well so that you can snap it back after you’re done sprinting. Also you’ll want probably want to use some form of Lerp to make it a smooth movement