annoying container picking

This forum is currently in read-only mode.
0 favourites
From the Asset Store
A well commented Dynamic Heart Containers template to learn from or to use as a base for your own game!
  • I absolutly love containers, however this is a little annoying:

    when you have two objects A and B in a container, call them A1 B1 for container instance 1 and A2 B2 for instance 2

    if A1 overlaps B1 it picks fine

    if A2 overlaps B1 it picks both B1 and B2 which is annoying

    as shown in attached cap

    anyone got a workaround?

  • Firstly, use the drag and drop movement! If you drag too fast, the objects are left behind with your code

    This is precisely how containers work. 'A overlaps B' naturally picks both the A instance and the B instance, which also picks the entire container of A and entire container of B.

    So what you want is to ignore the blue object's picking in this condition. You only want to pick the object that it was collided with, to save picking the blue object's own container as well.

    I've come up with a really funny workaround for this! Lets say A is the orange object, and B is the blue one.

    Use:

    + A overlaps B

    + For each A

    + A overlaps B

    -> Set A X position to .X + 10

    I *was* writing a short description of how it works, but to be honest, I can't figure out why this works. I would have thought the second condition would have still picked the entire container, but somehow the for-each overrides it. Ummm... I'm not sure if this is intended behavior or a bug. Hell, I say it's intended behavior. Because then, your problem is solved

  • haha thanks alot for the speedy response and workaround. Yeah I didnt really think it was a bug, I mean I expected that might happen I just couldn't see a way around it.

    lol, yeah I know that drag and drop thing was terrible, to be honest I haven't looked at the behaviors that much apart from physics and RTS, if this was an actual game or anything instead of a crappy little example I would of course have made it a lot better! Maybe in future I'll consider the behaviors

    EDIT: ahhh when I do that it crashes when it overlaps the one in the other container (reproducing a crash yay!)

  • OK weird... it works if you use a drag+drop behavior, but with your own drag events it crashes. I'll look later.

  • thats really weird, anyway, it works where I needed it to - so thats alright

    EDIT: was just thinking, maybe you could have some sort of "is not in container" condition, so you could have like A overlaps B and A is not in same container as B then it would pick the A and B that aren't in the same container - would be more intuitive than a for each object loop and another overlap condition which (by your own admission ) is confusing.

  • ok so I had to make it more complicated, and that broke it and now I can't make it work again.

    I need it to pick BOTH the objects, which by itself I managed, by copying the event and changing A to B and B to A - but now I need to only pick them when each of their private variables is a cirtain value

    I made a cap demonstrating my attempts and now I'm completely stuck - I've tried everything I can think of.

  • I have gotten slightly further (attached), but it is still bugged, and really horribly done. It seems to work like it should, but then when the correct ones overlap eachother and are picked, and you bring the other ones to collide with them, it stops it being picked .

    Basically I can't make this work, and I'm getting really frustrated by it lol

    so I am offering some incentive... if someone solves this, I will donate up to �10 to scirra, depending on the elegance of the solution (I am a student, so thats quite a lot of money to give away )

    1 event would be awesome, but if its like 20 events and loads of horrible private variables its only worth like �1

  • I'm gonna bump this because I still haven't found a solution and my offer still stands.

    IF YOU SOLVE THIS I'LL SEND ASHLEY �10

  • More flexibility with collision conditions is a common request, so I've added two new conditions for the System object in the next build: On Collision (advanced) and Is Overlapping (advanced). This has two object parameters to pick the objects involved in the collision, and two combo boxes - Pick or Don't pick - allowing you to customise which objects are picked by the condition.

    So, in this case, you can use:

    Blue (don't pick) overlaps Orange (pick): Set Orange X to .X + 10

    Then your example works fine: since Blue is not picked, it doesn't pick the Orange in its container, only the one it's colliding with. And it all works beautifully

    You should only use the advanced collision conditions when you need the specific picking behavior though - I don't think they're quite as fast as the usual ones.

  • More flexibility with collision conditions is a common request, so I've added two new conditions for the System object in the next build

    Wow, that sounds awesome

  • thank you so much this is brilliant, I feel like crying with happiness

    I'll donate on next patch when I can actually use it (even more than �10 if you add find/filtering lol)

  • ok so new build is out and it has advanced collisions...

    but I still can't make this work

    adding other conditions seems to completely break it still

    I have been trying for a while with no luck and a lot of confusion, and I don't know if it is working as intended as it is just picking both objects in one of the containers, and never the other container...

    Please help!!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah, there was actually a bug in the On Advanced Overlap code! That's why it wasn't working as expected at first... the fix will be in the next build, which will be 0.97.2, which won't be as long as the last build hopefully.

    Now your event, if you leave as-is, will always pick A, which picks the B in its container as well. That's going to make any events referring to B refer to the B in the same container as A.

    You can work around this by splitting up your event. With my fix applied ( ) the following works successfully as I think you want: the overlapping A/B objects rotate.

    + A (pick) and B (don't pick) overlap

    -> A: rotate 10 degrees

    + A (don't pick) and B (pick) overlap

    -> B: rotate 10 degrees

    If you do it in one event, B refers to the one in the container as the picked A. By using separate events, you can pluck out just the one instance that is overlapping and get around the containers that way. That should satisfy your needs... I hope!

  • Oh, and I can send you an updated runtime if you're desperate to try this out.

  • heh alright, glad I discovered a bug there then!

    Will it work with only when A's value is 1 and B's is 0? because this is important.

    I just had them both in the same event to show which of both it was picking, as I can't sort it out with the values aswell.

    It's like I need to pick then both in the same event, or at different times in the event...

    it needs to pick the collided ones, then make sure they both have the correct values, I managed it with one value, but not with both.

    something like:

    + B.value('m')=0

    + A (pick) and B (don't pick) overlap

    + A.value('n')=1

    -> A: rotate 10 degrees

    + A.value('n')=1

    + A (don't pick) and B (pick) overlap

    + B.value('m')=0

    -> B: rotate 10 degrees

    so out of the B's with m=0, if one collides with an A, it will unpick all the B's, pick matching A's, then pick the A's out of these with n=1 (and vice versa)

    The problem with that is, you put in B.value('m')=0 first, and then it picks the A's in it's container, so it will only count the collision with the A's in it's container, which I don't want it to count! If you put B.value('m')=0 after, there are no B's picked at all at that point, so it's useless.

    Maybe it's possible with the function object forgetting picking or something???? (I have no idea lol)

    Oh, and I can send you an updated runtime if you're desperate to try this out.

    would be nice

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