Sometimes SetMaterial() function does not activate when called on props.

Reference ID

72d4e2dc-4b60-5361-25b1-2681f979b427

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Summary

Am calling the SetMaterial() function on a large amount of props, and arbitrarily it seems like the function is just not working, despite the line being called? It seems very inconsistent. Sometimes everything functions perfectly, sometimes only a few work, etc.

Steps to Reproduce

  1. Create a custom material.
  2. Place 100+ props in the level.
  3. Write a verse script that loops over the props and changes their material to the custom material.
  4. Start the game a few times and observe.

Expected Result

Everytime, all props will have the new custom material.

Observed Result

Sometimes, an assortment of the props (either all of them or some of them) will have their default material instead of the new material.

Platform(s)

Windows

have you tried to Sleep(0.01) between calls? just an idea, sort of a workaround kind of thing

2 Likes

Oh, that’s a really good tip! It wasn’t originally in a suspends function so my head didn’t immediately jump to that, but doing that def makes it way more consistent. Instead of “sleep every one call” I’m doing a “sleep every X calls” so that it isn’t just doing 1 per frame. Setting it to like, ~30 before sleeping seemed like a good balance of consistency vs. breaking? After 50 it started to break a little.

Thanks for the advice, I appreciate it! Will keep this in time for any other times I’m making like, an unreasonable amount of calls to functions at once lol.

1 Like

you’re welcome!