Hello I’ve recently started scripting and I’ve been making an fps game and I’ve started to run to a lot of issues which is helping me since the trial and error processes makes me learn more and more with the community.
My question is how would I go about smoothly transitioning and objects local transform here is a script below but the object will only move a little bit since the Lerp is called only once instead of multiple times but I am not sure how to call it multiple times until the lerp is done?
if (Input.GetMouseButtonDown(1))
{
Transform gunTrans;
Vector3 NormalPos;
bool IsAiming = false;
if (IsAiming)
{
IsAiming = false;
gunTrans.localPosition = Vector3.Lerp(gunTrans.localPosition, NormalPos, AimSpeed);
}
else if (!IsAiming)
{
IsAiming = true; // If not obvious AimVector3 is the position I want to move the gun to the aim speed is the duration which is a float that is .25 seconds long.
gunTrans.localPosition = Vector3.Lerp(gunTrans.localPosition, AimVector3, AimSpeed);
}
}
Anyhow you can see what I mean its a basic branch type script with two if statements it will switch them between once I right click if I was aiming I aim out if I Wasn’t aiming it will aim? Any help is appreciated thanks for any help!