I NEED somebody to explain the Elevate Function

	RelativeSpeed = FMath::Clamp<float>(RelativeSpeed, -1, +1);
	auto ElevationChange = RelativeSpeed * MaxDegreesPerSecond * GetWorld()->DeltaTimeSeconds;
	auto RawNewElevation = RelativeRotation.Pitch + ElevationChange;
	auto Elevation = FMath::Clamp<float>(RawNewElevation, MinElevationDegrees, MaxElevationDegrees);
	SetRelativeRotation(FRotator(Elevation, 0, 0));

Can someone explain the math side of this code, plz?

and why we need DeltaRotator.Pitch? why we can’t pass AimRotation.Pitch as the endpoint?

Please, explain it to me as if I were a machine.

RelativeSpeed = FMath::Clamp<float>(RelativeSpeed, -1, +1);

This clamps the speed between -1 and 1. It is the percent of MaxDegreesPerSecond to rotate this frame.
The next line uses that to calculate the rotation amount needed for that frame. The majority of the time this will be MaxDegreesPerSecond * DeltaTime (or negative).

It will start to change when it gets closer to the target pitch. As now it shouldn’t move a full MaxDegreesPerSecond that frame otherwise it would overshoot. That is what multiplying it by RelativeSpeed will do, make it so it only moves a fraction of that.

If you were a machine you’d understand that code :sweat_smile:.

1 Like

I have one last little question :sweat_smile:
But first of all, thank you so much for the help. You always help me keep going.

What do you mean by frame? do you mean the Barrel?
Sorry if this Q is stupid, but I’m not a native speaker.

found some errors. you know this is the programmer’s/problem solver’s routine :sweat_smile:.

The frame being rendered to the screen.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms