Bounty Hunters Keep Rolling! (DevLog 01)
It's official, Godot has got me on edge! I'm so hyped up right now. It's no wonder a lot of indie dev's are falling in love with this amazing open source engine. So what's the deal with the weird looking sprite under a stack of brick walls? Its a rolling state, don't worry our sprite's not getting smashed to bits. Not yet. Thanks to an animation tree, I could accomplish something that would have otherwise been a nightmare to code, and I could do it all in my day job, without having to watch hours upon hours of tutorials. Well, only one tutorial by Heartbeast on youtube. HeartBeast Animation Tree
I realized two things working on my project. It doesn't really need a blendspace 2d, and it's a platformer so a simple state machine (animation node state machine in godot) would be enough for mostly everything since I needed absolute control in how states travel to one another and since I'm flipping the sprite when they move left or right along the x axis. I'm only using one animation per state. At least for this first set up of the game. The idle state being the central starting state, everything else leading out of it and back to it eventually.
Setting up the auto tiles was a little bit of trial and error. I also learned this from Heartbeats tutorial HeartBeast's Autotile with Collision
From what I can tell you, its like you red-out all the tiles that connect to each other and leave blank the sides of the edges of the corner and side tiles. I cant really explain it much in words as the Godot documentation already does a better job at that. Godot Using TileMaps
I'm amazed at how easy it is to setup collision in Godot. I have been messing with Love2d in the past and I know how difficult it is to attempt to setup collision programmatically using 2d arrays and parenthesis math's to calculate collision masks. In Godot you literally just draw shapes. That's it. Then make sure your player or enemies also have collision shapes. The rest is history! and then back to your game...
But that's not all folks! Godot has occlusion built in, think of this like a light based collision, so when you add light to your game, it creates shadows based on what the light occludes with. I've tried other engines such as game maker, even rpg maker to add lighting into the game and something as simple as a frickin shadow... you get the idea guys. It's otherwise some crazy shader maths or you just pay money for a plugin that doesn't really let you control much about the shadows or how they collide with light or anything at all. In Godot, you just draw shapes.
Although, I had one problem that I could not get over until just now, I have my character set up to roll under tight spots, however when they go under and you stopped pressing the move button the character would try to stand up between a rock and a hard place and get stuck, suspended in the air like their falling through a wall. I figured that this has something to do with my code and how I switch back to the idle and crouching animation states. So I did something I had a hunch about, I added a RayCast2D as a child to my KinematicBody (player node). Then I checked if my raycast2d was colliding along with if my state machine is currently in the rolling state. You know what I did right after that?
ABSOLUTELY NOTHING
Godot has a little statement called pass. It simply does nothing at all and skips that chunk of code. I tried the exact same thing with a return however the difference was return actually quits that code block and returns something if given a parameter. Pass on the other hand just skips that bit of code. It's a very subtly difference but in here return would sometimes skip the idle and crouching states because after quitting it checks again to see if the condition is true or not while pass just idly does nothing at all, it doesn't quit the condition also meaning that when we have our Ray Cast 2D colliding with the wall above (by the way it was set to a negative vector y of -16 when rolling, computers have y sort of flipped and by default it was not enabled and y was positive facing down) and while we are also rolling, don't travel back to idle or crouching states, just don't do anything at all and wait there. That's what pass will do and that's why bounty hunters keep rolling on while under a rock and a hard place.
Thanks to this awesome character pack by Clembod The Bounty Hunter Pack and Anokolisa's free amazing tileset Castle Prison and of course the indie no bullshit dream engine GoDot all this was possible to accomplish, sited at my work desk sipping a cup of coffee at my boring day job made not so boring. Let's hope we keep this going without getting laid off, on to the next one!
My Next Milestones are:
- I plan on adding in animation states for attacking in the air and on the ground
- Different guns and switching between them
- Wall slides, climbing ladders and hanging on the edge!
- Enemies, shooting and a complete Level.
Until Next Devlog. Happy game developing!