0 Favourites

[r100/101] can't pick object

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

    <img src="http://i.imgur.com/TIIwl.jpg" border="0" />

    Expected output:

    • created object with UID <uid>
    • picked object with UID <uid>

    Actual output:

    • created object with UID <uid>
  • 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.

  • 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'.

  • 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.

  • That's an important piece of information.

  • 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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • I think it can help...

    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.

  • 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.

  • *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.

  • 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.

  • Ashley

    Wait, now I'm confused. Does this mean that the subsequent set variable call on ObjA is not going to correctly pick the newly spawned ObjA?

    Event 1

    -- Spawn ObjA

    -- Set ObjA.MyVal = 1

    What about this one:

    Event 1

    -- Spawn ObjA (Instance1)

    -- Spawn ObjA (Instance2)

    -- Event 2

    -- -- Use ObjA

    I'm not doing explicit PICK calls, I'm just trying to use the current SOL. On Event 2, I would expect ObjA SOL collection to only contain Instance2 since it was the latest one. Is that correct?

    You mentioned that this is how it worked on Construct Classic but I really feel like this is an architecture issue that's going to happen again and again. Combined with the fact that objects of the same type cannot spawn another instance of themselves and I feel like conditional logic is going to get so messy from having to workaround these problems.

    Thanks,

    countofquad

  • countofquad - both your examples work correctly and the same they used to. It is only "sibling" subevents that act differently now.

    You can spawn objects of the same type, but they aren't picked. It should be easy to work around using system's 'create object' instead!

  • <img src="https://dl.dropbox.com/u/12667027/Construct%202/Picking%20Bug.png" border="0" />

    @Ashley: That's a relief then. But what about this?

    The highlighted command seems to fail, even though both Cloud and RainCloud belong to CloudFamily, I even changed it to be explicitly Cloud->SetOpacity and it still failed.

    I would have expected CloudFamily SOL to be the last created instance of a sprite belonging to that family.

    If this is intentional, that's really unfortunate, it seems like I'm going to have to setup lots of duplicate code in each branch.

    Please advise,

    Thanks!

  • countofquad - you can use the family's 'On created' trigger there to avoid code duplication.

  • Ashley,

    Thanks, I'm aware of that but the problem is that we're not guaranteed code order unless I purposely put the Event On Creation code at the bottom of the event sheet otherwise I'd have to wait for the game-loop to repeat.

    Additionally, I have lots of other previously picked SOL lists for other objects which happens in this event branch code, by the way it gets to the On Event Creation which is a top-most event, all of my SOL lists are no longer guaranteed to be the same.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
167 14,518
DMT2005's avatar
DMT2005
Unread hot topic
123 14,877
Zebbi's avatar
Zebbi
Unread hot topic
0 Favourites
Pick All / Create Bug
56 1,829
Prominent's avatar
Prominent