Making player bounce on top of enemy without taking damage!!

Chestosneako IncChestosneako Inc Member Posts: 25
edited February 2017 in Working with GS (PC)

I've already got a player that can bounce on top of enemy and destroy it after multiple hits. But for some reason I am not able to get the player to prevent damage when jumping on top of the enemy. It will just keep loosing health and I'm trying to only get the player to take damage when it collides to the side of the enemy, not when it jumps on top. Also the player keeps bouncing up in the air when it collides to the side and I only want it to jump when it hits on top of the enemy. Is there some way to get my character to ONLY jump when it's on top of my enemy and ONLY take damage when it collides to the side?!! Both the player and the enemy are taking damage at the same time when head jumping but I only just need the enemy to get destroyed for this specific action. I've done everything I could so now my only hope is to see if anyone can figure this out!!

EDIT: This "jump on enemy" attack is something similar to jumping on a goomba in Super mario bros.

Here are my rules for the player: https://drive.google.com/open?id=0B-lJpxbDBNVoaVJNWno4aUxRY0k

I've already followed this tutorial that demonstrates about head jumping and side collision but it doesn't mention anything about bouncing up after jumping on the enemy's head:

Comments

  • kianziackkianziack Member, PRO Posts: 28

    i've seen this question before hmmm try to search at google or youtube.

  • frdfrd Member Posts: 191

    Try using the y velocity as a test for whether the character should get injured or not.

    For example if y velocity is greater than or equal to 0 and it collides with enemy, then cause damage to hero, and if y velocity is less than 0 bounce up again. This should mean that when it lands on the enemy it will bounce up and wont get hurt, as it's y velocity is negative when going downwards, and when it collides with the enemy from the side it will get damaged but not bounce, as it's y velocity is 0 or positive.

    Sometimes I exaggerate it a bit to make it clearer, for example if y velocity is less than 10... this compensates for small bounces or unexpected -y values which you don't want to register.

  • Chestosneako IncChestosneako Inc Member Posts: 25

    @frd said:
    Try using the y velocity as a test for whether the character should get injured or not.

    For example if y velocity is greater than or equal to 0 and it collides with enemy, then cause damage to hero, and if y velocity is less than 0 bounce up again. This should mean that when it lands on the enemy it will bounce up and wont get hurt, as it's y velocity is negative when going downwards, and when it collides with the enemy from the side it will get damaged but not bounce, as it's y velocity is 0 or positive.

    Sometimes I exaggerate it a bit to make it clearer, for example if y velocity is less than 10... this compensates for small bounces or unexpected -y values which you don't want to register.

    I did exactly what you described but I'm not sure if I did it correctly, so I'll show you what I've done: https://drive.google.com/open?id=0B-lJpxbDBNVoSjI5VU5MTnNQZFU

    Once I did this, the player took damage from the side and didn't jump but when I tried jumping on top it didn't bounce this time and I still took damage. Perhaps I set up the rules incorrectly?! I did what I could but still not getting results!!

  • Chestosneako IncChestosneako Inc Member Posts: 25

    So is anyone going to check and tell me if I've done everything correctly based on the explanation that the other person gave me?! I've already given up with no new answers yet besides the ones I already have here so far. Otherwise I'm not going to have the player jump on the enemy anymore and leave it that way since this isn't possible for me to do!

  • rainwaterstudiosrainwaterstudios Member Posts: 198

    @Chestosneako Inc said:

    @frd said:
    Try using the y velocity as a test for whether the character should get injured or not.

    For example if y velocity is greater than or equal to 0 and it collides with enemy, then cause damage to hero, and if y velocity is less than 0 bounce up again. This should mean that when it lands on the enemy it will bounce up and wont get hurt, as it's y velocity is negative when going downwards, and when it collides with the enemy from the side it will get damaged but not bounce, as it's y velocity is 0 or positive.

    Sometimes I exaggerate it a bit to make it clearer, for example if y velocity is less than 10... this compensates for small bounces or unexpected -y values which you don't want to register.

    I did exactly what you described but I'm not sure if I did it correctly, so I'll show you what I've done: https://drive.google.com/open?id=0B-lJpxbDBNVoSjI5VU5MTnNQZFU

    Once I did this, the player took damage from the side and didn't jump but when I tried jumping on top it didn't bounce this time and I still took damage. Perhaps I set up the rules incorrectly?! I did what I could but still not getting results!!

    You could try adding this parameter:
    if self.position.Y < (enemyY+(enemyHeight/2)-10)
    to the 'Side Collision - Damage' rule; that way the health will only be affected if the character is too low to be counted as a top jump

Sign In or Register to comment.