Hello everyone, so on Section 55 of ObstacleAssault I’m having a problem with the platform’s location reset, basically what happens right now is:
Platform moves from 0 to 100
Teleports to 200
Moves back to 100
Teleports back to 0
Moves to 100
What should happen instead is a simple back and forth between 0 and 100, i looked at the code 5 times I see no difference between his and mine have i overlooked something?
Here’s code without comments:
FVector CurrentLocation = GetActorLocation();
CurrentLocation = CurrentLocation + PlatformVelocity * DeltaTime;
SetActorLocation(CurrentLocation);
float DistanceMoved = FVector::Dist(StartLocation,CurrentLocation);
if (DistanceMoved > MoveDistance)
{
FVector MoveDirection = PlatformVelocity.GetSafeNormal();
StartLocation = CurrentLocation + MoveDirection * MoveDistance;
SetActorLocation(StartLocation); PlatformVelocity = -PlatformVelocity;
}
PlatformVelocity is (100, 0, 0) while MoveDistance is 100.