Families: Is This Even Possible?

This forum is currently in read-only mode.
  • I have recently been developing a side project for me and a friend to play. Its an interesting take on the Shmup genre. I developed it from the ground up to be fairly modular and easy to add in things such as new characters and attacks, etc.

    However, I've seem to have run into a little snag...

    All of the (some 10 different types for each player) bullets are grouped together in a family, 'Bullets'.

    I need to set it so that the bullet with the lower PV 'Power' gets destroyed in the collision.

    However...

    "If 'Bullets' collides with 'Bullets'

    If 'Bullets.Value('Power') > Bullets.Value('Power')'"

    ...obviously isn't going to cut it.

    Any ideas on how to compare variables between two particular members of a family upon collision?

    (If it's a step in the right direction, each type of bullet DOES have a unique 'ID' variable)

  • Just use the private variable condition "pick with lowest value".

    so your event would look like this:

    + Bullets: On collision between Bullets and Bullets
    + Bullets: Pick with lowest ''Power''
    -> Sprite: Destroy
    [/code:1ngnyzu7]
  • Or even easier, add all your bullet objects into two families: Bullets1 and Bullets2. Then just check for collision between Bullets1 and Bullets2, and it becomes a piece of cake to differentiate between the two colliding instances.

  • R0J0hound: That method _ALMOST_ worked, except it also counts when the object collides with itself.

    Basically:

    P1 and P2 are shooting (pretty much rapidfire) bullets at each other, and we need to check when one players bullet collides with another players.

    Each bullet DOES have a PV 'Player' that is set from 1 to 4, depending on which player used it.

    That way if two players use the same character with the same attacks, it can still be differentiated.

    Daiz: That method didn't quite work, but I think I have an idea I'd like to try.

    I'll post results after experimenting, for future reference.

  • Basically:

    P1 and P2 are shooting (pretty much rapidfire) bullets at each other, and we need to check when one players bullet collides with another players.

    Each bullet DOES have a PV 'Player' that is set from 1 to 4, depending on which player used it.

    That way if two players use the same character with the same attacks, it can still be differentiated.

    Daiz: That method didn't quite work, but I think I have an idea I'd like to try.

    How did it not work? It should work exactly as you want, since I've used the exact technique myself as well. In your case, the events would go something like this:

    Conditions:

    + Bullets1 colldes with Bullets2

    + Bullets1 value 'player' is different to Bullets2 value 'player'

    Actions:

    • Destroy Bullets1
    • Destroy Bullets2

    No matter what the object is, as long as it's in two families differentiating between colliding instances is very easy.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Or even easier, add all your bullet objects into two families: Bullets1 and Bullets2. Then just check for collision between Bullets1 and Bullets2, and it becomes a piece of cake to differentiate between the two colliding instances.

    This method works well, but you need to use something like this as condition, using "is overlapping (advanced)" or "On collision (advanced)":

    For each Bullet1

    ---For each Bullet2

    ------On collision between Bullet1 (Pick) and Bullet2 (Pick)

  • Ok, I ended up going with combining Aritz's and Daiz's ideas and it worked fine!

    Thanks a ton guys, this was getting really frustrating

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