Does the game object created by obj_factory have a sprite? Your call to go.set tries to set the property image on the game object and not on the sprite component. Try something like:
local sprite_url = msg.url(nil, object, "spriteid") -- change to id of your sprite
go.set(sprite_url, "image", go.get("#script", "atlas"))
Haven’t found anything like that. To be more precise, once I run the build (Ctrl + B) it loads for a while and then gives me a common crash window (Win8) with “dmengine” header and “Stopped working…” .
Found nothing like crash report or anything like that.
UPD: I’ve got some error message in console after all. It’s in the next post.
Got it. Sprite inside is called “object”, so I get correct URL and Atlas hash. But the build still crashes, just gives some info this time.
url: [main:/instance0#object] newAtlas: hash: [/data/cres/e2.texturesetc]
ERROR:GAMESYS: Unable to play animation 'a5' from texture '/_generated_8042a01f.texturec' since it could not be found.
ERROR:GAMESYS: Unable to play animation 'a0' from texture '/_generated_8042a01f.texturec' since it could not be found.
Assertion failed: i < m_Count, file C:\buildbot\slave\builds\engine-win32-64-master\build\engine\gamesys\build\default\proto\texture_set_ddf.h, line 41
a5 here is a default image from atlas used in factory, a0 is image from the new atlas that should replace a5.
Well, that’s strange that I have to add whole URL, since there’s msg.post directly to object in the nex line.
Plus I’ve successfully replaced image by the same atlas in another object which isn’t an instance. So it looks like either it crashes because I try to change an instance sprite this time, or because of the wrong addressing.
This will send the “play_animation” message to all components on the game object. So it works, but it’s not as efficient as sending a message directly to the intended component. I would also assume that it could result in problems if you have multiple sprite components and some of the doesn’t have the animation with id animation.
Could you please provide a minimal repro case for us to look into?
WOW… seems like I just accidentally reproduced/fixed that. Factory’s object “default animation” contained a sprite, which is absent in a replacing atlas. And it chashed the whole build.
Assertion failed: i < m_Count, file C:\buildbot\slave\builds\engine-win32-64-master\build\engine\gamesys\build\default\proto\texture_set_ddf.h, line 41