Verse Library verse

08 Randomly Selecting Valid Platforms

Randomly enables or disables collision and changes light colors on platform entities within a grid structure.

extracted-snippets/documentation/en-us/fortnite/spawning-a-grid-of-platforms-with-scene-graph-in-unreal-editor-for-fortnite/08-randomly-selecting-valid-platforms.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/spawning-a-grid-of-platforms-with-scene-graph-in-unreal-editor-for-fortnite
# Local doc:  epic-docs/documentation/en-us/fortnite/spawning-a-grid-of-platforms-with-scene-graph-in-unreal-editor-for-fortnite.md
# Section:    Randomly Selecting Valid Platforms
# Randomly choose platforms to have collision in the row.
RandomizeCollidablePlatformsPerRow(Entities:[]entity):void=
# Disable all the entities before choosing which ones to enable.
# It disables an entity by disabling the collision on the entity,
# and finding a point light in its child entities to change its color.
for:
EntityPlatform : Entities
Collision := EntityPlatform.GetComponents(collision_component)[0]
Light := EntityPlatform.FindComponents(point_light_component)[0]
do:
Collision.Disable()
Light.SetColor(NotChosenColor)
# Enable an entity by enabling the collision on the entity,
# and finding a point light in its child entities to change its color.
if:
ChooseOneResult := RemainingEntities.ChooseOne[]
ChosenEntity := ChooseOneResult(0)
Collision := ChosenEntity.GetComponents(collision_component)[0]
Light := ChosenEntity.FindComponents(point_light_component)[0]
then:
Collision.Enable()
Light.SetColor(ChosenColor)

Comments

    Sign in to vote, comment, or suggest an edit. Sign in