Change the Car's Colours
Change the Car's Colours
A paint job is the cheapest thrill in any car game. Let's add one — and learn the real, sometimes-restrictive truth about materials in Verse.

The honest truth about materials
<!-- section-art:the-honest-truth-about-materials -->

Material Swap
You might expect a SetColor or SetVectorParameter call. It doesn't exist for creators. In build 41.00 the material class is <epic_internal>: its SetColorProperty / SetFloatProperty methods are internal, and there is no public material_parameter_collection, dynamic_material, or per-parameter setter anywhere in the API. You cannot tweak a material's colour value from Verse.
What you 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) in your project, expose them as editable slots, and cycle through them on a button press. Same car body, instant new look.
Editable material slots: the ?material idiom
There's a wrinkle. Because material is internal, you can't write material{} to give a data member a default — the compiler rejects the constructor. The idiom is to declare the slot as an optional that defaults to false:
@editable
PaintA : ?material = false
The editor fills the slot with a real material asset; in code you unwrap it with PaintA?. (Try PaintA : material = material{} and you'll get "Invalid access of epic_internal class constructor" — proof of the rule.)
Cycling the paint
<!-- section-art:cycling-the-paint -->

Paint Cycle Swap
On each button press we advance an index 0 → 1 → 2 → 0 and apply whichever slot is filled:
OnPaintPressed(Agent : agent) : void =
if (Next := Mod[PaintIndex + 1, 3]):
set PaintIndex = Next
if (PaintIndex = 0, Paint := PaintA?):
ApplyPaint(Paint)
else if (PaintIndex = 1, Paint := PaintB?):
ApplyPaint(Paint)
else if (Paint := PaintC?):
ApplyPaint(Paint)
Two small Verse details earn their keep here. Mod[...] is a failable (<decides>) call, so we compute it inside an if and then set the variable — you can't put a failable expression on the right of a set. And each branch tests two things at once: the index matches and the optional unwraps (Paint := PaintA?), so an empty slot is simply skipped.
ApplyPaint does the actual swap on every tagged car body:
ApplyPaint(Paint : material) : void =
for (Obj : FindCreativeObjectsWithTag(car_body_tag)):
if (Body := creative_prop[Obj]):
Body.SetMaterial(Paint, ?Index := 0)
Note ?Index := 0 — SetMaterial's index is a named optional parameter, so it's passed with the ?Name := value syntax, not positionally.
The full device
Compile-verified in UEFN 5.8. Tag your car body car_body_tag, a button car_paint_button_tag, drop three Material assets into the slots, and press to cycle.
Recap
- There is no public per-parameter colour API —
materialis internal; you swap whole materials. creative_prop.SetMaterial(Material, ?Index := 0)is the one public paint call; the index is a named optional.- Declare asset slots as
?material = false(you can't constructmaterial{}); unwrap withPaint?. Mod[...]is failable — compute it in anif, thenset.
Get the complete code — free
You've read the full walkthrough. The complete, copy-paste-ready Verse solution is free for members — sign in to unlock it.
Free with your BrainDead.TV / BrainDeadGuild Discord account. The walkthrough above is always free.
Verse source files
- 01-fragment.verse · fragment
- 03-device.verse · device
Check your understanding
Test yourself with an interactive quiz and track your progress + earn XP — free for members.
Turn this into a guided course
Add UEFN Verse materials — the public creative_prop.SetMaterial whole-material swap (no per-parameter colour API exists); @editable ?material = false idiom; Mod failable + named optional ?Index to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.
References
Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.