Change atlas of a factory object (crashes my build)

Me again. Sry, seems like that change atlas thing is a new feature, so I can’t find anything on that. =(

local object = factory.create ("/factory#obj_factory", x, y)
go.set(object, "image", go.get("#script", "atlas"))

It crashes the whole thing. Even the debug field is empty. Maybe I’m addressing those image fields incorrectly.

And another question. If I add the same atlas to 10 instances, will they use the same one or they will instantiate atlases too?

Thank you!

Thanks for reporting. Please also read this: getting help

Also, what does the callstack say?
Please provide the _crash file (or _crash.dmpon Windows)

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.

msg.post (object, “play_animation”, {id = hash (“open”)})

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.

britzl

After some experiments it seems there’s no need in making another URL. Since

local sprite_url = msg.url(nil, object, "spriteid") -- change to id of your sprite
go.set(sprite_url, "image", go.get("#script", "atlas"))

seems equal (results in same error) to

go.set(object, "image", go.get("#script", "atlas"))

because

local sprite_url = msg.url(nil, object, "spriteid") -- change to id of your sprite
msg.post (sprite_url , "play_animation", {id = hash ("animation")})

is equal to

msg.post (object, "play_animation", {id = hash ("animation")})

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?

2 Likes

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.

Got some event logs in case you need them:

crashes.zip (13.0 KB)

And here’s what it gives me in Console

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

I’d like to look into this. I’d very much appreciate if you could take the time to create a minimal repro case for this. Thanks!

1 Like