UnrealScripterAI
Discord ↗
Link Copied to Clipboard
×
"script that updates the speed of the spacecraft"
// Update the Speed of a Spacecraft void ASpacecraft::Tick(float DeltaTime) { Super::Tick(DeltaTime); if (bIsAccelerating) { CurrentSpeed = Acceleration * DeltaTime; if (CurrentSpeed > MaxSpeed) { CurrentSpeed = MaxSpeed; } } else { CurrentSpeed -= Deceleration * DeltaTime; if (CurrentSpeed < 0.0f) { CurrentSpeed = 0.0f; } } FVector Movement = GetActorForwardVector() * CurrentSpeed * DeltaTime; AddActorWorldOffset(Movement); }