playMaker

Author Topic: Destroy object/kill enemy  (Read 1503 times)

Gojtan

  • Playmaker Newbie
  • *
  • Posts: 9
Destroy object/kill enemy
« on: June 28, 2020, 06:24:06 PM »
Hi!

I'm trying to do a 2D-sidescroller, but I'm having issues with fighting enemies.

Think like Mario Bros, I wanna jump on my enemys head, he will then die, but if the enemy walks into me, I will die.

So I want something like if enemy Y.pos is lower than my Y.pos and there's an impact = enemy dead
If my y.pos is somewhat the same as enemies, I die on impact.

Any ideas?

Also any ideas of how to make the enemy die in a "better looking way", I.E. falling down, off the camera or something like that, before using Destroy.

Cheers!

Athin

  • Full Member
  • ***
  • Posts: 163
Re: Destroy object/kill enemy
« Reply #1 on: June 29, 2020, 02:14:55 AM »
Heya,

Simple collision boxes can do this.  Have one above the head of the enemy for the "Kill shot".  Then have one more that covers the rest of the enemy for the enemies attack.  Make a trigger event to fire off as soon as one is touch and do whatever you want it to do.

From there, you can play different animations depending on what got hit.

FYI depending on how much you got destroying/creating then pooling maybe something to look into.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Destroy object/kill enemy
« Reply #2 on: June 29, 2020, 02:23:24 PM »
Hi.
I would probably use some raycast (as probably you already need them for 'Grounded')

for death animation, there are many ways and ideas, best is to play several 2d platformers to get some inspiration.

Also as Athin said its good to look into pooling for any object that you will be using several times (like coins / enemies / power ups)
Create/Destroy is 'Expensive' and leaves lots of 'garbage'
Pooling Disables/Enables objects (in short) so you can reuse them somewhere else.

Gojtan

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Destroy object/kill enemy
« Reply #3 on: July 05, 2020, 12:00:34 PM »
Heya,

Simple collision boxes can do this.  Have one above the head of the enemy for the "Kill shot".  Then have one more that covers the rest of the enemy for the enemies attack.  Make a trigger event to fire off as soon as one is touch and do whatever you want it to do.

From there, you can play different animations depending on what got hit.

FYI depending on how much you got destroying/creating then pooling maybe something to look into.

Damn, how did I not come up with this myself lol :D Thanks alot though!


Hi.
I would probably use some raycast (as probably you already need them for 'Grounded')

for death animation, there are many ways and ideas, best is to play several 2d platformers to get some inspiration.

Also as Athin said its good to look into pooling for any object that you will be using several times (like coins / enemies / power ups)
Create/Destroy is 'Expensive' and leaves lots of 'garbage'
Pooling Disables/Enables objects (in short) so you can reuse them somewhere else.

Raycast might be another option, but I think collision boxes is the easiest way for this!

I will only have like 3-4 enemies per level so I think create/destroy is fine for this game lol =p It's just a small game for my online course.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Destroy object/kill enemy
« Reply #4 on: July 05, 2020, 05:01:41 PM »
Hi.
If you are making a course i would suggest to actually use pooling.

As it is something you will use a lot in many games :)

On the Ecosystem you have a simple pool system action set called Pooler Pool.