How to destroy enemy by the player jumping over its head ?

Get help using Construct 2

Post » Wed Jun 11, 2014 5:53 pm

Hi all,

In my platformer game, I've some enemies who moves vertically from top to bottom and I want that the player should be able to kill them by jumping over their heads, but if the player touches the body of the enemy the player should die.

I tried to implement it the following way:

Image

But it's not working perfectly. Most of the times the player would not die if it touches the body of the enemy and many of the times the enemy won't die if the player touches its head.

Can you please help me on this? Where could I be wrong?
B
5
Posts: 16
Reputation: 261

Post » Wed Jun 11, 2014 8:56 pm

I would make an invisible collision sprite that follows the enemy around above their heads. Put it in a container with the enemy. If player overlaps that kill sprite for more than say 0.25 seconds destroy the enemy.. that's the easiest way I can think of doing it.

Image
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
27
S
8
G
3
Posts: 384
Reputation: 5,020

Post » Wed Jun 11, 2014 8:57 pm

actually make the sprite narrow enough and center it over the enemy and you dont even need a delay really, since they technically have to be like halfway over the head of the enemy to kill it.
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
27
S
8
G
3
Posts: 384
Reputation: 5,020

Post » Wed Jun 11, 2014 8:59 pm

Oh wait you want the enemy to die when you land on it? Like a Goomba / mario enemy? You mentioned you want to kill it when you jump "Over" it so i ran with that. Sorry.
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
27
S
8
G
3
Posts: 384
Reputation: 5,020

Post » Thu Jun 12, 2014 5:19 am

In Mario, kill versus death when the player touches an enemy is decided by whether the player is falling or not.
B
47
S
14
G
7
Posts: 603
Reputation: 8,141

Post » Thu Jun 12, 2014 9:25 am

80bit wrote:I would make an invisible collision sprite that follows the enemy around above their heads. Put it in a container with the enemy. If player overlaps that kill sprite for more than say 0.25 seconds destroy the enemy.. that's the easiest way I can think of doing it.

Image


Just make a small sprite sticked on the enemy's head, whenever your character touch the sprite the enemy dies
B
8
S
2
Posts: 203
Reputation: 1,169

Post » Thu Jun 12, 2014 9:32 am

One of the things I love about Construct2 is you're able to test for overlaps at an offset. That way you don't actually need a separate object for collision testing purposes.
B
6
S
1
Posts: 41
Reputation: 762

Post » Thu Jun 12, 2014 10:40 am

Is that .capx are you looking?
You do not have the required permissions to view the files attached to this post.
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Fri Jun 13, 2014 7:16 am

80bit wrote:I would make an invisible collision sprite that follows the enemy around above their heads. Put it in a container with the enemy. If player overlaps that kill sprite for more than say 0.25 seconds destroy the enemy.. that's the easiest way I can think of doing it.


80bit wrote:actually make the sprite narrow enough and center it over the enemy and you dont even need a delay really, since they technically have to be like halfway over the head of the enemy to kill it.


Thanks a lot, but yes..that didn't work because I wanted to kill the player if it touches the enemy elsewhere than head. Appreciate your help : )

EncryptedCow wrote:In Mario, kill versus death when the player touches an enemy is decided by whether the player is falling or not.


I tried that but sometimes its falling and touches the enemy on its side instead of head, so it didn't work well.

EightBitBattleCat wrote:One of the things I love about Construct2 is you're able to test for overlaps at an offset. That way you don't actually need a separate object for collision testing purposes.


It didn't work as expected.

Joannesalfa wrote:Is that .capx are you looking?


That capx is from the new beta verion.. I've the r168 version currently, so didn't try : ( but thanks!


ijoin wrote:Just make a small sprite sticked on the enemy's head, whenever your character touch the sprite the enemy dies


Perfect! Worked like a charm. Thanks a ton!

I created another sprite (just as the way @80bit described) but instead of putting it in a container with the object, I pinned it to the object. That made it work perfectly.

Thanks a lot everyone :)
B
5
Posts: 16
Reputation: 261

Post » Fri Jun 13, 2014 7:18 am

To create a mario like effect, I want to add a bounce off effect when the player touches the enemy's head. I tried setting simulate jump to the player when it touches the pinned sprite on the enemy's head, but that is not making the player jump :(

Any solution?
B
5
Posts: 16
Reputation: 261

Next

Return to How do I....?

Who is online

Users browsing this forum: Coren8r, Yahoo [Bot] and 28 guests