Hi,
I am trying to rotate 4 rectangular, moving platforms so that they go from this sort of shape ¬ to a backwards looking L:
So basically, I want it to rotate 90 degrees.
I have some code already but it just does not seem to work:
if (bNoSpawn == true)
{
for (TActorIterator<ALevelGen> ActorItr(GetWorld()); ActorItr; ++ActorItr)
{
ActorCount += 1;
if (ActorCount == 1)
{
Actor1Position = ActorItr->GetActorLocation();
}
//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, ActorItr->GetActorLocation().ToString());
}
//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::FromInt(ActorCount));
// GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Bool: %s"), bTurnLeft ? TEXT("true") : TEXT("false")));
if (Actor1Position.X <= -500 && ActorCount == 4)
{
// GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Actor position is less than value"));
FRotator ActorRotation = TypingRunCharacter->GetActorRotation();
if (bTurnLeft == false)
{
//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Turn right"));
ActorRotation.Yaw += 90 * DeltaSeconds;
//TypingRunCharacter->SetActorRotation(ActorRotation);
for (TActorIterator<ALevelGen> ActorItr(GetWorld()); ActorItr; ++ActorItr)
{
ActorCount2 += 1;
FVector ActorPosition2 = ActorItr->GetActorLocation();
ActorItr->SetActorRotation(ActorRotation);
ActorPosition2.Y = 0;
//if (ActorCount == 1)
//{
// ActorPosition.X = 0;
//}
if (ActorCount2 == 2)
{
ActorPosition2.X = 8000;
}
else if (ActorCount2 == 3)
{
ActorPosition2.X = 9000;
}
else if (ActorCount2 == 4)
{
ActorPosition2.X = 12000;
}
ActorItr->SetActorLocation(ActorPosition);
}
SetCurrentState(ETypingRunPlayState::EPlaying);
bNoSpawn = false;
ActorCount2 = 0;
}
else
{
//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Turn left"));
ActorRotation.Yaw -= 90 * DeltaSeconds;
//TypingRunCharacter->SetActorRotation(ActorRotation);
for (TActorIterator<ALevelGen> ActorItr(GetWorld()); ActorItr; ++ActorItr)
{
ActorCount2 += 1;
FVector ActorPosition3 = ActorItr->GetActorLocation();
ActorPosition3.Y = 0;
//if (ActorCount == 1)
//{
// ActorPosition3.X = 0;
//}
if (ActorCount2 == 2)
{
//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Actor Counter = 2"));
ActorPosition3.X = 8000;
}
else if (ActorCount2 == 3)
{
ActorPosition3.X = 9000;
}
else if (ActorCount2 == 4)
{
ActorPosition3.X = 18000;
}
ActorItr->SetActorRotation(ActorRotation);
ActorItr->SetActorLocation(ActorPosition);
}
SetCurrentState(ETypingRunPlayState::EPlaying);
bNoSpawn = false;
ActorCount2 = 0;
}
}
ActorCount = 0;
}
I’m checking where the platforms end up and they’re all here:
X= -10 Y = 0 Z = -179337712
But if I frame skip to the point where the platforms should rotate, the Z coordinate stays at 0 (which it should) but the X still goes to -10 for each of them.
Occasionally, this doesn’t happen.
Any help would be greatly appreciated.