Actors not rotating/moving correctly

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.

Hi, one thing I notice is that

ActorRotation.Yaw += 90; and ActorRotation.Yaw -= 90;

if should be something like:

 ActorRotation.Yaw += 90 * DeltaSeconds; and ActorRotation.Yaw -= 90 * DeltaSeconds;

to be in sync with the CPU clock. If you are not using the tick function, then you would get the timer like this:

float DeltaSeconds = GetWorld()->GetDeltaSeconds();

are these platforms staying in the same position at all times?

Hi there.

Thanks for that. I’ve tried that now and it seems to have done something different but not the right thing, unfortunately. The platforms all seem to go to the same coordinates now (even the one that I’m currently not trying to move).

X= -10
Y = 0
Z = -179337712

Not really sure what’s going on there…

Edit: Just noticed that the Z coordinate doesn’t go all crazy if I frame skip to the point where the platforms should move but the platforms end up going to X=-10 all the same

Can you make a video of it? :slight_smile: rotation goes up to 360 degrees.

are the platforms in a blueprint?

Thanks for your help so far but I managed to figure out it (finally)! Just problems with my logic in places + I needed to do this as you mentioned earlier:

ActorRotation.Yaw += 90 * DeltaSeconds; and ActorRotation.Yaw -= 90 * DeltaSeconds;

I would have never got that bit by myself haha.

Issue was down to logic problems and spazchicken’s suggestion of:

ActorRotation.Yaw += 90; and ActorRotation.Yaw -= 90;

if should be something like:

ActorRotation.Yaw += 90 * DeltaSeconds; and ActorRotation.Yaw -= 90 * DeltaSeconds;

np, glad you figured it out!