Failed to find pin object by UID when loading from JSON.

Discussion and feedback on Construct 2

Post » Fri Dec 19, 2014 1:55 pm

Image

This is the error I'm receiving.

This error occurs when the game attempts to "load" a screen.

My game is saving each object's JSON data to a key=value array.

Upon loading, it loops through this array, and for each object of type A, creates object A and loads A from JSON at Array.CurX,1 (where CurX,1 is the JSON data of the object that was saved.)

I had assumed that the pin properties would be correctly saved and recalled by saving the object AsJSON and loading it back from that data. Either this is the incorrect method or I'm just doing something wrong.

Any suggestions?
B
4
Posts: 15
Reputation: 232

Post » Fri Dec 19, 2014 4:10 pm

objects created dynamically are not guaranteed to have the same UID.

Since your creating the object through a loop any object created at any time can offset that. It's unreliable to rely on the same UID. I suggest reading on UID and IID. UID are id value that is the same pool of id's as all objects.

So the pin properties are probaly fine. But there was a mistaken use of applying the data.

If you can share a snippet of the work that focuses on this error(no third party plugins please). Then we can take a look and find an alternative.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Fri Dec 19, 2014 6:25 pm

Sure, I'll post that up this evening.

The reason the UID error is strange is because I'm not actually pinning based on UID in my events. I'm pinning based on creation and overlap... so when object A is created, create object B and pin it to object A at X image point.

Thanks for the reply!
B
4
Posts: 15
Reputation: 232

Post » Fri Dec 19, 2014 8:04 pm

Okay, here is where the object is being created and pinned to the other object:

Image

And here is where it's being loaded... this is when the error occurs:

Image
Last edited by VocoRobo on Fri Dec 19, 2014 10:41 pm, edited 1 time in total.
B
4
Posts: 15
Reputation: 232

Post » Fri Dec 19, 2014 9:58 pm

Those images are broken for me.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Fri Dec 19, 2014 10:42 pm

Tried to change the links hopefully that'll work. Did them the same way as the one in the OP.
B
4
Posts: 15
Reputation: 232

Post » Sat Dec 20, 2014 3:09 am

hmm. could you link a minimal capx, I think I need a larger picture of what's going on.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Sun Dec 21, 2014 4:57 am

Sure.

I've attached it to this post.

You'll find the "problem areas" under the Sector Gen Group -> LoadSector function (this is actually the function that is causing the error, when it tries to load the pinned object)

The pinned object is created under Enemy AI Group -> NME Ship

I stripped out everything that wouldn't prevent enough function to replicate the error.

To see the error, simply go off any edge of the screen, then go back to the last screen, then return to the one you just visited. When it tries to load a screen with an enemy ship+turret is when the error occurs.
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 15
Reputation: 232

Post » Mon Dec 22, 2014 6:14 am

Sorry the link was broken. Didn't realize until later in the day.

I've attached the capx to the prior post.
B
4
Posts: 15
Reputation: 232

Post » Tue Dec 23, 2014 5:13 pm

I've managed to overcome the issue by introducing a "wait for signal" in the event that loads the turrets. This works with or without an actual signal, so it appears that the timing is an issue. By delaying the loading of the JSON data for the turret just a small amount it is able to find and pin to the proper object.
B
4
Posts: 15
Reputation: 232

Next

Return to Construct 2 General

Who is online

Users browsing this forum: jobel, paxto22 and 5 guests