Some tips for the moving platforms

Hello everyone,

In the Trigger Platform code it is useful to do a validation check for each element of the Trigger platform array and check if the amount of actors is greater than 0:

  if (LinkedPlatforms.Num() > 0)
  	for (AMovingPlatform* Platform : LinkedPlatforms)
  		if (Platform) Platform->IncreaseActiveCounter();

If you accidentally added a new element in the editor but forgot to assign a platform, it would cause a crash. Also you should want to make sure there is at least one actor linked :slight_smile:

If you want to reverse the behaviour of the platform, where it stops moving when someone stands on the trigger platform you can do it easily like so:

  // Ignore movement if Active Counter is 0 or less and not paused when active.
  // Ignore movement if Active Counter is 1 or more and paused when active.

  if ((ActiveCounter <= 0 && !bPauseWhenActive) || (ActiveCounter > 0 && bPauseWhenActive)) return;

Just make sure you declare a new boolean in the header file and set it to EditInstanceOnly. :slight_smile:
(I renamed ActiveTriggers to ActiveCounter by the way!)

1 Like

Thanks for sharing.