Instance Picking Issues + First Instance of an Object Ignoring Collisions.

Not favoritedFavorited Favorited 0 favourites
  • 13 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • This is a two problem issue and both seemingly feed into each other so let me start with the first one. There's 2 parts to this. I have this code set up to where if an Enemy (The Koopa here in this case) comes into contact with another enemy while in the Kicked state, it calls the "genericdeath" custom action. This works *most* of the time. However, when it comes into the first object in the room created, it doesn't do anything. It just sort of phases through it. I tried destroying the first object and noticed that it then starts to fade through the next object that'd be in line after that object is destroyed. I have no idea what to make of this at all.

    Second issue is that sometimes it'll call GenericDeath for multiple enemies at the same time. From my testing, this seems to usually happen if one Enemy is Overlapping another enemy regardless of whether or not they're actually hit by the enemy that should be killing them.

    I've provided all of my koopa code that applies both on the family and individual level. As well I have provided each state variable and the generic death function. Sorry this is a lot of code I know, but I feel like the extra context is needed here. Also all the images are in order descending.

  • is Enemies action a plugin ? you might not be picking any specific Enemy in there unless it works like a function with copy picked. For this one you probably have to share the project.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Short of access to the actual project and someone taking time to look through it it won’t be possible to debug.

    That said areas you could focus your attention on is the “or” blocks and “trigger once” conditions. Or blocks tend to bite me often so I carefully ensure they are doing what I intend when I use them.

    Maybe putting a for each in the custom actions may help too. In general many find it simpler to use “for each” in any place that there may be multiple picked instances to make the logic more clear to them.

  • is Enemies action a plugin ? you might not be picking any specific Enemy in there unless it works like a function with copy picked. For this one you probably have to share the project.

    Custom Actions aren't a plugins they're a built in Construct 3 Feature. They basically work like a function with copy picked like you suggested.

    Sorry for the late reply had to gut the project, this file should have everything relating to the issue. You can observe the glitch within the layout. You can add more or remove the koopas I placed down and compare the first few instances to the rest. I also kept in a Goomba enemy just to showcase how it interacts with other enemies in the same family.

    Link: dropbox.com/scl/fi/088qak5kwnblsr2ht3wap/GuttedKoopaProject.c3p

    I honestly don't mess with For Each that much since I find it usually tanks my performance but that's probably just me (unfortunately) being a spaghetti coder lol

  • I trimmed down your project to 15 events and the bug was still happening. For the KoopaHitBox on collision with Enemies I changed it to KoopaHitBox is state 9 and overlapping Enemies and it was fixed. There might be an issue with the on collision event and it being in the same family, which is strange as this method is used to solve collision problems between same object types.

  • I trimmed down your project to 15 events and the bug was still happening. For the KoopaHitBox on collision with Enemies I changed it to KoopaHitBox is state 9 and overlapping Enemies and it was fixed. There might be an issue with the on collision event and it being in the same family, which is strange as this method is used to solve collision problems between same object types.

    Bizzare... Yeah I've tried this method for other things too and have never had this problem. I don't know of another (easier) way to do collisions between 2 object types. I have no idea why that specific state screws everything up though. Maybe I'll report this as a bug if it's a C3 bug?? In the meantime should probably try to find another way to have them collide with each other. Have no idea how to go about that, though

  • A collision is only checked once per pair of instances. It doesn't evaluate both "A collides with B" and "B collides with A" as separate events... they're the same collision. As a result, only one instance ends up being picked, and in your case it may not be the one where EnemyState = ENEMY_STATE_KICKED. It happens in C2 as well... I don't think the dev will fix it though.

    But here's another fix for it apart from overlapping

    As for the 2nd issue... I can't seem to reproduce it

  • Here is the chopped down version where the issue still happens. I spent some time on it but can't figure out why unless it is a conflict with family/container. The overlap check does fix it because it runs more often but I would still expect the on collision event to run for each collision.

    dropbox.com/scl/fi/rkv2qtwbs8162mzaio2bj/koopamodified.c3p

  • lionz My solution works because it picks the instance before the collision trigger is evaluated.

    I'm pretty sure On collision is unordered in C2/C3. Because of that, having On collision and EnemyState = ENEMY_STATE_KICKED in the same event doesn't guarantee the picked Enemy is the kicked one. If Construct happens to pick the other instance for that collision pair, the condition fails.

  • A collision is only checked once per pair of instances. It doesn't evaluate both "A collides with B" and "B collides with A" as separate events... they're the same collision. As a result, only one instance ends up being picked, and in your case it may not be the one where EnemyState = ENEMY_STATE_KICKED. It happens in C2 as well... I don't think the dev will fix it though.

    But here's another fix for it apart from overlapping

    As for the 2nd issue... I can't seem to reproduce it

    Oh huh, yeah that did fix it. Thanks for the help. I have a hunch that the 2nd issue might have been correlated with that but I'm not sure. When I got it to happen it was pretty random, with a few exceptions. Sometimes it would fail sometimes it wouldn't. I'll probably have to come back to it at some point but I'll just put it on the list of "things to fix in the future".

  • lionz My solution works because it picks the instance before the collision trigger is evaluated.

    I'm pretty sure On collision is unordered in C2/C3. Because of that, having On collision and EnemyState = ENEMY_STATE_KICKED in the same event doesn't guarantee the picked Enemy is the kicked one. If Construct happens to pick the other instance for that collision pair, the condition fails.

    It should narrow the picked instances of hitbox to only the ones with that variable set or that's how it used to be and it used to be suggested that trigger events should be used at the top level so adding conditions like that under 'on collision' would be the only way to narrow the pool. I understand what you mean but in the past I never had a problem filtering in that way, it acted like an if hitbox collides with enemy and the variable is set then run the event, as in both the things have to be true for it to trigger.

  • lionz

    From the manual,

    If a trigger is in a sub-event, all of its parent event's conditions must be true at the time the trigger fires, otherwise the event will not run.

    I do remember seeing a post mentioning that triggers should be kept at the top level. However, based on testing and the current manual, I don't think moving the trigger to the top level is necessarily the best solution in this case.

    And yes, filtering/picking first can work better when you're dealing with two different object types rather than instances of the same object type, so that may have been what was happening in your case.

  • lionz

    From the manual,

    If a trigger is in a sub-event, all of its parent event's conditions must be true at the time the trigger fires, otherwise the event will not run.

    I do remember seeing a post mentioning that triggers should be kept at the top level. However, based on testing and the current manual, I don't think moving the trigger to the top level is necessarily the best solution in this case.

    And yes, filtering/picking first can work better when you're dealing with two different object types rather than instances of the same object type, so that may have been what was happening in your case.

    my point is more that it should just work in its simplest form and it doesn't in this project.

    I have had no problems with sprite + var set on collision with fam then apply actions to the fam in my own projects. So my point is that there must be a fix to have it working with the collision event at the top level not in a sub event but for this project I haven't found that fix even when I chopped down the events to less than 20.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)