Help with two objects fusing/breaking apart

This forum is currently in read-only mode.
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I did the art for a friend of mine's game, but this is my first try using construct, after watching him fiddle around.

    Most of the included things are for aesthetics, like the fire-mosquito and sunlight. The dirtbunnies (black dots, green eyes) are the gameplay element I need help with. They float around alright, but what I plan to have them do is all start out small. I created a "Size" Private variable for this, which they all start out on '1'. Start of layout, they float around randomly. I want the Size 1 bunnies to collide, and become Size 2 bunnies. Then as the bunnies collide I want a size (x) and a size (y) to become a Size (x+y), but if a Size (x if x>1) and a Size (x if x>1) collide, they just bounce off each other. I've tried a few things, all ending in failure.

    Example if my above wording is too confusing:

    Two Size 1 bunnies collide, they become a size 2 bunny.

    A Size 2 and a Size 1 bunny collide, they become a Size 3 bunny.

    A Size 3 and a Size 2 bunny collide, they become a Size 5 bunny, and so on...

    Two bunnies bigger than Size 1 but of the same Size collide, they bounce off each other.

    Each increase in 'Size' should increase the bunnies size (height and width) by around 6 units.

    I intend to later on add in some sort of weapon (time detonated bomb?/chain-strike weapon?)

    that will split any affected bunnies in half (aka Asteroids effect).

    Thanks for any help! Here's the cap.

    http://dl.getdropbox.com/u/676998/DustB ... hetics.cap

  • to check for collision between two instances of the same object, you would need to put that object into 2 different families (e.g. red and green). you can then use a condition like 'red: on collision with green' and follow that up with subevents managing your behavior:

    + red: on collision with green
        + green('size') is equal to red('size')
            + green('size') is greater than 1
                > bounce
            + green('size') is equal to 1
                > merge
        + green('size') is not equal to red('size')
            > merge[/code:1j1tg4ri]
  • I've been wondering about collisions between different instances of the same sprite! The family approach sounds great.

    But in this case, I tried the approach using the families, and it mostly worked, but crashed sometimes and I couldn't figure out why.

    Then I tried a horrible approach that *didn't* use families, just to see if it was possible. This worked without crashing, but sometimes created enormous beasts due to inherent flaws in the method.

    Collision between the dust bunny sprites was always unreliable: sometimes it'd work, sometimes it'd ignore the collision. This happened in all circumstances: family or sprite collision, 'collision' or 'overlapping'. I'm still puzzled about that one.

    I might go try this in a minimal setting, to see if I can reproduce the crashes (or better yet, create a working solution). Here's the cap, if anyone's curious.

    http://dl.getdropbox.com/u/906550/assist.cap

    PS: Great sunlight!

  • Okay, so...

    Here's a working cap:

    http://dl.getdropbox.com/u/906550/assist-2.cap

    (Not quite how you described it, but should be easy to modify.)

    Here's how the principle looks in a minimalist setting.

    http://dl.getdropbox.com/u/906550/Test2.cap

    It seems there's a bug in families: 'on collision' between families works fine, but 'on overlapping' sometimes causes a crash. I'll submit this to the tracker.

    Collision detection between dust bunnies still seems weird in your cap, but it's okay in the minimalist one. Baffling.

  • Perhaps it would be intelligent to use a second sprite by bounding box instead of by pixel collision tied to the dirt bunny.

  • That does work:

    http://dl.getdropbox.com/u/906550/assist-3.cap

    But it works even if you make the bounding box sprite exactly the same as the original dirt bunny sprite and use per-pixel collision.

    So the per-pixel collision isn't the problem.

    Maybe a bug?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Erm. That is annoying. Oh well.

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