Verse Library verse

03 Device

Swaps material assets on creative props to instantly change vehicle colors without complex material editing.

verse-library/verse-car-material-colors/03-device.verse

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Simulation/Tags }
using { /Verse.org/Assets }
using { /UnrealEngine.com/Temporary/Diagnostics }

# CHANGE THE CAR'S COLOURS — Part 2 of "Scene Graph: Car Primitive".
#
# Players love a colour swap. The honest truth about Verse + materials in build
# 41.00: there is NO public per-parameter API. `material.SetColorProperty` /
# `SetFloatProperty` exist but are Epic-internal, and there is no
# `SetVectorParameter` / `material_parameter_collection` / `dynamic_material`
# anywhere in the public surface. What a creator CAN do is swap the WHOLE
# material on a placed prop with one public call:
#
#   creative_prop.SetMaterial(Material : material, ?Index : int)
#
# So the recipe is: author a few material assets (a red paint, a blue paint, a
# gold paint), expose them as `@editable ?material` slots, and cycle through them
# on a button press. Same car body, instant new paint job.
#
# Note the `?material` (optional) type: the `material` class is Epic-internal and
# cannot be constructed with `material{}`, so a concrete device can't give it a
# plain default. Declaring the slot as `?material = false` is the idiom — the
# editor fills it in, and Verse unwraps it with `Paint?`.

car_body_tag := class(tag) {}
car_paint_button_tag := class(tag) {}

car_material_colors_device := class(creative_device):

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