Logic Problem?

This forum is currently in read-only mode.
From the Asset Store
100 items casual and logic games. All icons are of a high quality.
  • So I'm making a game where you have a rock shooting cannon and you hit birds with rocks.

    -Once a rock hits a bird, it's physics are enabled and it falls

    -Once a bird hits a bird, it's physics are also enabled which will be what triggers combos

    -The birds fly across the screen at random Y locations

    Problem:

    Before I hit a bird with a rock and 2 birds collide, they will both fall. I only want a bird to effect another bird after it has been hit with a rock.

    I've tried fixing this by giving a private variable to a bird, making it true once a rock hits it, and checks if the bird is being hit by another bird with the property as true, but to check a private variable of an object only checks it's own private variable, not the private variable of another object.

    I hope that makes sense, I'm really lost here. I'll upload the .cap if anyone needs it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Post the cap chap and I will take a look.

  • http://www.mediafire.com/?gitp6ab339lp4uo

    Here you go. Good luck. I tried to redo it but got the same results.

  • http://dl.dropbox.com/u/1487524/Scirra/Birds.cap

    here you go. I have added comments as to what was going on.

    I would also recommend you investigate the physics behaviour some more, particularly the gravity and ways to toggle that off and on when the birds get hit.

  • Steven solved the logic problem nicely with the check for being 'active', but on my machine, there is a different problem that remains:

    + Sprite2: On collision between Sprite2 and Sprite2

    That causes somewhat random crashes on my machine. Construct has no good way to differentiate between the two different instances of Sprite2 there, and it seems to cause problems.

    In the event that you've not had to deal with such a problem before, I'll discuss a common way to deal with it.

    The easy way to deal with needing to pick two different instances of the same object in the same event is to add that object into a family (let us use Blue family.) Here, if a Sprite2 is 'active' and has collided with any other Sprite2, the other Sprite2 is also set to 'active':

    + Sprite2: Value 'active' Equal to 1

    + Sprite2: On collision between Sprite2 and Blue

    -> Blue: Set 'active' to 1

    In this way, any actions performed upon Sprite2 within that event will only affect Sprite2 objects that have the 'active' var set and have collided with a Blue family member (which only contains Sprite2 objects here.) Any actions performed upon Blue in that event will only affect the Blue member that was collided with by the aforementioned Sprite2 object.

  • Silent Cacophony - I also had a few crashes during the collisions. I will keep that little work around in mind if I run into things like that in my project.

  • dl.dropbox.com/u/1487524/Scirra/Birds.cap

    here you go. I have added comments as to what was going on.

    I would also recommend you investigate the physics behaviour some more, particularly the gravity and ways to toggle that off and on when the birds get hit.

    Awesome, other than the crashing, it works great, thanks man.

    + Sprite2: Value 'active' Equal to 1

    + Sprite2: On collision between Sprite2 and Blue

    -> Blue: Set 'active' to 1

    This also got rid of the crashing. It's perfect now and I'll definitely use this method in the future.

    The core of the game is pretty much finished now thanks to you guys. I have a few features to add and it'll be done. Yay!

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