gdquest-demos / godot-platformer-2d

2d Metroidvania-inspired game for the 2019 GDquest Godot Kickstarter course project.
MIT License
623 stars 74 forks source link

First rough pass at enemy as hookable #163

Closed Razoric480 closed 5 years ago

Razoric480 commented 5 years ago

Wanted to get a very basic example going for review, with as little changes to player as possible.

It doesn't check all the boxes of the tasks (enemy doesn't damage player, nor does it get knocked back) but what is currently in there was done with no change to Player states. Thought it'd be worth a look to make sure it's not doing any no-no or falling into a pitfall I didn't see coming.

NathanLovato commented 5 years ago

Nice start. Regarding the jump it's not what I had in mind:

In other words, when the player hooks onto the enemy:

  1. It moves to the enemy like a normal hooking point, and the hook itself damages the enemy
  2. The player automatically uses the enemy as a stepping stone to jump or hop vertically

Number 2. is so that the player has a bit of time in the air to aim and hook onto another target.

If it's not clear, I can tweak the prototype to show the idea

Razoric480 commented 5 years ago

Changed it up with your revision. Hope that's closer to what you had in mind.

NathanLovato commented 5 years ago

One step closer, but not there yet. I'll do the next iteration to show what I mean, as it's a matter of game design and game feel. The way the character hooks jumps and jumps now gives no sense of impact or combat in general, it would also make it hard to aim for the next enemy

NathanLovato commented 5 years ago

There you go, I added a small commit to show you the idea: the player stops on the enemy's back for an instant, then jump. The idea would be to have a nicer animation/interaction between the two, but at least that's a start.

Code-wise, I don't know how we could best handle having the player propel himself from the enemy's body, i.e. knocking back the enemy when the player does that jump. One option would be to pass the enemy to the player's HopOnEnemy state, but I'd rather not control the enemy from the player's code and vice-versa. One thing that could work would be a one-time signal connection on the enemy, to make it react to the player having hopped.

NathanLovato commented 5 years ago

The changes are here: https://github.com/GDquest/godot-platformer-2d/pull/163/commits/113f83e35824e43f97b12f39290c464fac34790f

Razoric480 commented 5 years ago

I see! Okay, I get it now. I'll work with it from that angle.

Razoric480 commented 5 years ago

Moved whether the player state goes into HopOnEnemy out of the enemy, and instead having the Hook state of the player object transition to HopOnEnemy if the hook target was a KinematicBody (otherwise transition to Move/Air as normal.)

It seems to play pretty alright, and keeps the code from infecting one another, but I'll let you judge.

NathanLovato commented 5 years ago

I left a few code style/guideline-related comments, but in general it's looking good. To me, the only thing left for this pass is making the player temporarily invincible after killing an enemy: if there's an enemy above the player, the jump after hooking onto an enemy will kill you.

But that may be a task for another branch because I think this should interact with the health system. Health should be external to the state machine and handle everything related to health and invincibility.

NathanLovato commented 5 years ago

So if you think it is good to merge now, we can merge this first pass and add that later. 🙂

Razoric480 commented 5 years ago

Now should be good to merge! Will be moving on to new branch.