Verse Library verse

04 Get Components Of An Entity

Defines a reusable component that hides and shows an entity in a timed loop using custom methods.

extracted-snippets/documentation/en-us/uefn/creating-your-own-component-using-verse-in-unreal-editor-for-fortnite/04-get-components-of-an-entity.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/creating-your-own-component-using-verse-in-unreal-editor-for-fortnite
# Local doc:  epic-docs/documentation/en-us/uefn/creating-your-own-component-using-verse-in-unreal-editor-for-fortnite.md
# Section:    Get Components of an Entity
using { /Verse.org }
using { /Verse.org/Native }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SceneGraph }
# A Verse-authored component that can be added to entities.
# This component will make the entity appear and disappear on loop.
disappear_on_loop_component := class<final_super>(component):
# How long in seconds the entity should be hidden.
@editable
var Duration<public>:float = 2.0
# Runs when the component should start simulating in a running game.
# Can be suspended throughout the lifetime of the component. Suspensions
# will be automatically canceled when the component is disposed or the
# game ends.
OnSimulate<override>()<suspends>:void =
# Wait for the specified number of seconds then hide the entity,
# and wait again before showing the entity.
loop:
Sleep(Duration)
Entity.Hide()
Sleep(Duration)
Entity.Show()
# An extension method for the entity type that hides the entity,
# by disabling its mesh component.
(Entity:entity).Hide():void=
if:
Mesh := Entity.GetComponent[mesh_component]

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

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