How do I collisions with different object from same type

  • i have a weapon that shoots canonballs

    now since i have different collisions with different objects i had to make events for each on collision differently.

    (some are hit differently from the others)

    anyway now i want to add another type of bullet (let's say fireball for example), and i want everything else to work

    exactly as it is, but i don't want to duplicate code.

    so if i put events like this:

    cannonball  on collision with object
    or
    fireball on collision with object           -  do something.. blah blah, and then... destroy fireball, destroy cannonball[/code:3vi72xa8]
    
    is this a good practice? will it bug out when there's no cannonball ?
  • The way you are doing it will work, but will quickly make your events unreadable. If you are only going to have two bullet types, this may be fine. If you add any more, it won't.

    If you have a license, families would really be the best way to do this. Add all the bullet objects to a family and create a family level event for these collisions.

    If you are using the free version, families are not available but there is still an easy way to have this collision event work for all your bullet types. Just use the same object with different animations for your bullets. So, instead of having a Cannon Ball object and a Fire Ball object, you would have a Bullet object with a Cannon Ball animation and a Fire Ball animation.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • yes, that's exactly what i needed, didn't think of it before (different animations ),

    thnx a lot!

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