Devlog 03 Collision Detection

I just finished the 3rd video in this playlist series on adding collision detection. Now you can walk around a barrel and punch it from either side. Your sprite flips depending on the side you are on so the punch can go left or right. We added a mini state machine for the barrel so when you punch it, it can show the broken barrel state. I really liked how we coded the increasing alpha channel on the barrel so it didn't just queue_free it slowly disappeared. That was a nice touch. I did have some challenges with punching to the left. If I was on the right side of the barrel, pressed the left arrow so my sprite and punching hand were facing the barrel correctly, if I pushed the C key to attack, the sprite just flipped the other way. No punches, no attack. It's weird because if the player is on the left side, and punches right everything works as expected. I was too tired to go back and see if the directions were wrong or I did it wrong because I was able to get it working. Also the maker of the tutorial interacted on Youtube a bunch with me until it was working so it didn't matter. I also looked at the Github repo and found what I thought was going to be the error. He too makes commits after each section, AND has a project state at each commit so if you make a mess of everything in one state, you can go to the next tutorial, and download the project the way it should look at that point. It's super helpful and that's what I do with my own students in bigger projects. It really takes the fear out of making mistakes or tinkering around, since you know no matter how much you change you can always download a version as it should be.
This was the code for the function I had wrong. I had Vector2.RIGHT and not ZERO for some reason. Once that was fixed, you could be on the right side and punch left, with no flipping back. YAY!
func handle_movement() -> void:
if can_move():
if velocity.length() == 0:
state = State.IDLE
else:
state = State.WALK
else:
velocity = Vector2.ZERO
Files
Get MODDED Beat Em Up game
MODDED Beat Em Up game
Status | In development |
Author | Fuzzy |
Genre | Fighting |
Tags | Beat 'em up |
More posts
- Devlog 0210 days ago
- Devlog 01 Getting started beating em up12 days ago
Leave a comment
Log in with itch.io to leave a comment.