A bit confused about the parameter rotationThisFrame

Hi @u4icfln! Welcome to the community

rotationThisFrame is a parameter to a function

void ApplyRotation(float rotationThisFrame /* <-- it's here */)
{
    transform.Rotate(Vector3.forward * rotationThisFrame * Time.deltaTime);
}

When ProcessRotation is running, it passes a value to ApplyRotation, and this value is named rotationThisFrame inside ApplyRotation

void ProcessRotation()
{  
    if (Input.GetKey(KeyCode.A))
    {
        ApplyRotation(rotationThrust); // <-- Here it passes rotationThrust
    }
    else if (Input.GetKey(KeyCode.D))
    {
        ApplyRotation(-rotationThrust); // <-- Here it passes -rotationThrust
    }
}

So, Depending on which key you pressed (A or D) the value of rotationThisFrame will be equal to either rotationThrust or -rotationThrust

1 Like