My Solution to send platform back

My take on the solution. Tried to do is as tight packed as possible.

FVector Direction = (GlobalTargetLocation - GlobalStartLocation).GetSafeNormal();
// We comparing if we are going forward or backward and have we crossed the Start or the End location. Then change the boolean.
Forward && FVector((GlobalStartLocation - GetActorLocation())).Size() > FVector((GlobalStartLocation - GlobalTargetLocation)).Size() ? Forward = false : !Forward && FVector((GlobalTargetLocation - GetActorLocation())).Size() > FVector((GlobalTargetLocation - GlobalStartLocation)).Size() ? Forward = true : 0;
Forward ? SetActorLocation(GetActorLocation() + (PlatformSpeed * Deltatime * Direction)) : SetActorLocation(GetActorLocation() + (PlatformSpeed * Deltatime * Direction *-1));
1 Like

Privacy & Terms