void APlayerRunner::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (GEngine) {
GEngine->AddOnScreenDebugMessage(0, 0.5f, FColor::Red, TEXT("Internal Power: ") + FString::SanitizeFloat(IntPower));
}
Velocity = GetVelocity().Size();
Grounded = APlayerRunner::GetCharacterMovement()->IsMovingOnGround();
if (Velocity != 0 && Grounded)
{
SubPower(PowerMult * (Velocity / MaxSpeed) * GetWorld()->DeltaTimeSeconds);
GetCharacterMovement()->bOrientRotationToMovement = true;
}
else {
GetCharacterMovement()->bOrientRotationToMovement = false;
}
}
This may be a dumb question but I haven’t coded in a while
The game I am trying to achieve is a modified version of the unreal battery collector game. The player has an internal power supply that only depletes when he/she moves and is in contact with the ground.
Now this code works just fine however I feel that I’m not efficiently using GetCharacterMovement()->bOrientRotationToMovement = Whatever correctly since I’m using the function every tick.
Is this the proper way of doing it? Should I be doing it in a different way? Is there a better way? I ask because every tick the function runs and I feel like that’s a waist of processing to change that specific Boolean.
Probably just overreacting