[r100/101] can't pick object

Bugs will be moved here once resolved.

Post » Fri Aug 31, 2012 7:29 am

This code works in r99 but not in r100 or r101:


Expected output:
- created object with UID <uid>
- picked object with UID <uid>

Actual output:
- created object with UID <uid>
B
22
S
9
G
5
Posts: 122
Reputation: 5,386

Post » Fri Aug 31, 2012 1:28 pm

I have the same problem and now my whole project is broken, because the main functionality is based on this "feature".

It seems to be, that you can't pick objects, that were just created(spawned). Picking objects out of the family in this way is also broken in versions 100 & 101.

Right now in order to fix that I have to repeat the same code for like 30 different objects.
B
42
S
11
G
4
Posts: 505
Reputation: 7,267

Post » Fri Aug 31, 2012 2:06 pm

Yea, I also noticed that suddenly a whole lot of things were behaving weirdly in my finished project and I think this is causing it in several places. I don't think it's a feature though because, well, it was working before, and the code looks technically correct, and I checked the release notes and didn't see any 'breaking changes'.wgfunstorm2012-08-31 14:07:55
B
22
S
9
G
5
Posts: 122
Reputation: 5,386

Post » Fri Aug 31, 2012 2:36 pm

This is by design I'm afraid, and was discussed in another similar thread.

In short creating objects and then using them in subevents is unstable for various reasons, and can cause crashes. So this had to be fixed, and now created objects do not exist until the top-level event finishes. (This is how it always worked in Classic btw, and for the same reason, so it was a bug that C2 has been letting you get away with possibly unstable events.) They are picked in their own subevent, but in subsequent subevents they don't exist yet. It is very difficult to work around this without simply putting it back which results in some projects crashing and not working at all, so I think it has to stay like this instead.

I assume the events you screenshotted are in a subevent, which is important because it affects the result.

The workaround is just to put subsequent subevents nested under the event that created the objects instead, or in this case a subsequent event is not necessary because you can just use the created instance in the same event.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Fri Aug 31, 2012 3:23 pm

That's an important piece of information.
B
42
S
11
G
4
Posts: 505
Reputation: 7,267

Post » Fri Aug 31, 2012 10:06 pm

Yes, that's one of the easier ones to fix out of the 4 I have found so far. The most frustrating part is not knowing which of my 3000 events are now broken. For example the christmas hats that only appear on level 21 were now being positioned incorrectly. But what about the ones I haven't found? The game is done, tested, debugged. Now I have to organize some testers again and re-test it all because I just know I'm going to miss one, or cause a weird knock-on edge case bug through my fixes.

Anyways, I'll stop ranting, it's not really constructive. I understand it's a difficult situation. Sorry, I'm just frustrated.

Practical question! How would you recommend solving this trickier situation:


(click for higher res)


I can't nest the subevents under the event that created the object because sometimes I want to use the new object, and sometimes I want to re-use an existing object. I guess I could branch and duplicate the code so that I have it once for when a new object is created, and a 2nd time for when the object is reused but that's less than optimal.wgfunstorm2012-08-31 22:12:54
B
22
S
9
G
5
Posts: 122
Reputation: 5,386

Post » Sat Sep 01, 2012 3:26 pm

I think it can help...

http://www.scirra.com/tutorials/361/understanding-uid-iid-health-of-enemies-and-rocket-smoke-trail

You can simple make instace variables and conditions where only the instance variable of that specific object can meet.
ImageImageImageImageImageImage
B
93
S
20
G
12
Posts: 1,213
Reputation: 18,484

Post » Sat Sep 01, 2012 9:06 pm

That's what I do with the bSelected instance variable. But the problem is that when the object has been newly created, since r100 you can't use this method to select it until the top-level event has finished.
B
22
S
9
G
5
Posts: 122
Reputation: 5,386

Post » Mon Sep 03, 2012 4:47 pm

*bump*

Any suggestions? The tl;dr of what I want to do is:

- several sub-events deep
-- select object with instance variable bSelected=true
-- if no object with bSelected=true exists, create it
-- do something with the object

Since the object is sometimes newly created, I can't pick it. But I also can't nest the code under the creation because it isn't always a new object.
B
22
S
9
G
5
Posts: 122
Reputation: 5,386

Post » Mon Sep 03, 2012 5:30 pm

I think you have to duplicate the subevents for each branch (created vs. use existing). Hopefully this will be easier in future when we add function features built-in.

I am sorry that this causes difficult compatibility problems, but sometimes we have to make breaking changes. It's better we change it now than leave it in the long run with a known crash.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Next

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest