Hi! First off thanks for taking the time to look at this, I really appreciate it.
I'm making a 2d sidescroller and i was wondering what would be the best way to set up a hit detection system. I had one that consisted of adding to an alterable value everytime an animation is played and the characters overlap until it reaches a value and then it deletes the enemy. It was very sloppy though and put multiple hits on the enemy when i only wanted one. I need help freezing the enemy after a hit has landed.
I also need help establishing a cooldown for when the player is hit similar to sonic or mario (when they blink after they're hit and are invulnerable for a few seconds).
I'm using the Newgrounds edition of TGF2.
Maybe set it so that the enemy can be damaged only when a Flag is not tripped; as soon as the player's animation causes a hit on the enemy, the flag is tripped, and is reset once the player is no longer overlapping the enemy.
You can also make it flicker so that when the player is overlapping the enemy and the flag is tripped, the enemy flickers. The enemy will stop flickering once there is no overlap.
Not at my MMF2 computer at the moment so I can't test it out for you, but have a go at the above and see what happens.
Jake, I see this is your first post, so Welcome to TDC!
I believe something like this ought to work:
// character hits player, unless they're still invincible
+ Enemy: hitTimer = 0
+ Enemy is overlapping Character
+ Character: animation "attack" is playing
+ Character: animation frame = whatever...
-> Enemy: set hitTimer to 150
-> Enemy: subtract 1 from hitPoints