Setting Materials with parameters from verse Not working after v33.00

Summary

After the latest update v33.00 Setting instanced materials from verse seems to be broken.
Instancing materials like this var my_material : MaterialHere_material = MaterialHere_material{} sometimes works and sometimes doesn’t
and having them inside an array var my_material : []MaterialHere_material = array{MaterialHere_material{},MaterialHere_material{},MaterialHere_material{}}seems to not work at all

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Assets

Steps to Reproduce

  1. Create a Materials that has parameters (Material should show up in assets.digest.verse with a suffix of _material appended to their name)
  2. Place a creative_prop in the world
  3. Create a verse_device that has as a class variable multiple instances of the material in an array, and a reference to the creative_prop placed in the world
  4. Inside the OnBegin Function get the material from any index of the array (EXCEPT INDEX 0) and set that material to the creative_prop using the creative_prop.SetMaterial() function

Expected Result

Setting the material of a prop through verse should have the material apply In-Game

Observed Result

The material is NOT changed

Platform(s)

windows

Upload an image

Video

Additional Notes

In the video two identical cubes were placed with one getting the material set directly by instancing a material on the spot (The Material is applied correctly)
And the other cube is getting the material set by first getting the material instanced from the array (Index 2) and then setting it (The Material is not applied)

Files of the project the Video was made on:
ProjectFiles.zip (4.1 MB)

I am seeing this exact issue in my project as well. I started right after v33.0.

Initializing a material including parameters via a class variable initializer produced a material that could not be set:

var my_material : MaterialHere_material = MaterialHere_material{}

I could call .SetMaterial() using my_material, but the new material would not be applied.

After I moved my material initialization inside a method on the class, the issue was fixed and the material could be applied and parameters changed.

1 Like

Thanks a lot for the detailed and concise repro. The attached project in particular was very useful in identifying what’s happening here.

The issue stems from the array being stuck at the size it was when you added it to the map in the first place. If you place a device into the level while 2 elements exist in code, then add another element in code and recompile, the instance of the device in the level will remain at 2 elements. In your example project it appears the device would have been added to the level with only a single element and the code was updated afterwards?

This isn’t directly related to materials and is a bit of a bigger problem which we are working to address. But in the mean time you may be able to work around this issue by replacing the device with the correct number of elements after a recompile. Or you might be able to leverage an @editable array to populate the elements.

1 Like

FORT-831464 has been ‘Closed’ as a duplicate of an existing known issue.