How do I collisions with different object from same type

Get help using Construct 2

Post » Thu Apr 23, 2015 8:30 am

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:

Code: Select all
cannonball  on collision with object
or
fireball on collision with object           -  do something.. blah blah, and then... destroy fireball, destroy cannonball


is this a good practice? will it bug out when there's no cannonball ?
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
42
S
14
G
12
Posts: 625
Reputation: 9,423

Post » Thu Apr 23, 2015 3:33 pm

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.
B
39
S
12
G
11
Posts: 331
Reputation: 7,727

Post » Thu Apr 23, 2015 6:10 pm

yes, that's exactly what i needed, didn't think of it before (different animations :) ),

thnx a lot!
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
42
S
14
G
12
Posts: 625
Reputation: 9,423


Return to How do I....?

Who is online

Users browsing this forum: amazingdream, Yahoo [Bot] and 21 guests