Verse Library verse

04 Material Parameters

Spawns three props and randomly applies a parameterized material color at runtime.

extracted-snippets/documentation/en-us/fortnite/exposing-assets-with-asset-reflection-to-verse-in-unreal-editor-for-fortnite/04-material-parameters.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/exposing-assets-with-asset-reflection-to-verse-in-unreal-editor-for-fortnite
# Local doc:  epic-docs/documentation/en-us/fortnite/exposing-assets-with-asset-reflection-to-verse-in-unreal-editor-for-fortnite.md
# Section:    Material Parameters
using { /Fortnite.com/Devices }
using { /Verse.org/Colors }
using { /Verse.org/Random }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
# A Verse-authored creative device that spawns three props and randomly changes their color
material_color_test_device := class(creative_device):
# Reference to the parameterized material in the Assets.digest.verse file.
MyParameterizedMaterial:ConcreteMaterial_material = ConcreteMaterial_material{}
OnBegin<override>()<suspends>:void=
Offset:vector3 = vector3:
X := 200.0
Y := 0.0
Z := 0.0
# Spawn several props to apply the material to.
SpawnResult1 := SpawnProp(DefaultCreativePropAsset,GetTransform().Translation,          GetTransform().Rotation)
SpawnResult2 := SpawnProp(DefaultCreativePropAsset,GetTransform().Translation + Offset, GetTransform().Rotation)
SpawnResult3 := SpawnProp(DefaultCreativePropAsset,GetTransform().Translation - Offset, GetTransform().Rotation)
# Set the material on each of the props.
if:
Prop1 := SpawnResult1(0)?
Prop2 := SpawnResult2(0)?
Prop3 := SpawnResult3(0)?
then:
Prop1.SetMaterial(MyParameterizedMaterial)
Prop2.SetMaterial(MyParameterizedMaterial)

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