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;
//TypingRunCharacter->SetActorRotation(ActorRotation);
for (TActorIterator<ALevelGen> ActorItr(GetWorld()); ActorItr; ++ActorItr)
{
ActorCount += 1;
FVector ActorPosition2 = ActorItr->GetActorLocation();
ActorItr->SetActorRotation(ActorRotation);
ActorPosition2.Y = 0;
//if (ActorCount == 1)
//{
// ActorPosition.X = 0;
//}
if (ActorCount == 2)
{
ActorPosition2.X = 800;
}
else if (ActorCount == 3)
{
ActorPosition2.X = 3980;
}
else if (ActorCount == 4)
{
ActorPosition2.X = 7160;
}
ActorItr->SetActorLocation(ActorPosition);
}
SetCurrentState(ETypingRunPlayState::EPlaying);
bNoSpawn = false;
ActorCount = 0;
}
else
{
//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Turn left"));
ActorRotation.Yaw -= 90;
//TypingRunCharacter->SetActorRotation(ActorRotation);
for (TActorIterator<ALevelGen> ActorItr(GetWorld()); ActorItr; ++ActorItr)
{
ActorCount += 1;
FVector ActorPosition3 = ActorItr->GetActorLocation();
ActorPosition3.Y = 0;
ActorItr->SetActorLocation(ActorPosition);
//if (ActorCount == 1)
//{
// ActorPosition3.X = 0;
//}
if (ActorCount == 2)
{
//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Actor Counter = 2"));
ActorPosition3.X = 0;
}
else if (ActorCount == 3)
{
ActorPosition3.X = 3680;
}
else if (ActorCount == 4)
{
ActorPosition3.X = 6860;
}
ActorItr->SetActorRotation(ActorRotation);
}
SetCurrentState(ETypingRunPlayState::EPlaying);
bNoSpawn = false;
ActorCount = 0;
}
}
ActorCount = 0;
}
Any ideas? Something definitely seems to rotate but then my character just gets stuck on the platform for a bit and then falls off.