Get Num Materials doesn't work on Begin Play

Not sure if this a bug or just a limitation of how engine handles initialization. I made it with a spawned BP in 4.6.1. Interestingly it works with a delay that is zero seconds long. I guess that is then 1 tick when it is set to 0.

Hi Davison,

I wasn’t able to reproduce behavior you described. If I spawn an actor on begin play and then print return from Get Num Materials, it gives me correct value. Can you give me some images of your setup that was not working? Thanks!

I’m pretty sure I know now what it was. There is a “set mesh” after “spawn actor” and that mesh comes with a different material count. So I guess what was happening is that set mesh and begin play was happening at same time or set mesh just takes a little time.

Yep, that makes sense. Giving it that extra tick to finish setting mesh is probably what resolved issue for you. Let us know if you have any more trouble with it!