Learn You a Game Jam - Night 6 - Structure!


So I had a bad night, but woke up in the AM hours and had a break through.

I was having no end of trouble with colliders not working the way I thought they should, and spent most of the evening trying to get them working when I wanted to be building out the Character / Item / Type structure that is basically the entire game.  I went to bed after a few hours of flicking on and off layers and masks and checking code and animation and putting up debug prints that were all telling me the same thing... your collision layers aren't the problem.

I was thinking about colliders wrong, in particular the relationship between a CharacterBody2D and a StaticBody2D that is its child.  I was trying to have a Core CharacterBody2D that blocked everything, then a larger StaticBody2D Body around the core that block foes and took damage put allowed friends to pass.  Then an optional ZoneOfControl StaticBody2D where you block foes but don't take damage.

The problem with the Body in this set up was that it can't push against the CharacterBody2D without ejecting it, so you turn off its mask for the Core.  But then the Body and Core basically ignore each other, except that the Body is a child of the core and will stay with its position.  Even if it can't technically push through an foe's collider, it will because its a child of the core, and the core isn't effected by the foe's collider yet, and the core and the body don't collide... just share the same position.

Basically I can't use the CharacterBody2D as the Core, it has to be the Body.  I was doing it the other way mostly because the collider for CharacterBody2D has to be directly under the CB2D node or it doesn't work.  I can use script and the TypeStats to update this collider when the Type is loaded, so its not a big adjustment.

The other good news is that I build my first Item.  The Sword of Recruitment is an item whose sole purpose is to tell the Character to load the MainTank Type core into the Character's TypeSlot... and it works!

Create a character scene.  Make children editable so you have access to the Item slot.  Put the Sword in the Item Slot, and play the game. The Character script checks for an item in the slot and will default to a Guildie (not built yet) if Affiliation is Guildies.  If its anything else or blank it will default to a slime.  It loads the Slime base Character Stats and Type core into the Type slot, and then the Character is a fresh Slime.

If it sees an item in the Item Slot it will use the Item's data to load the Type core instead.  Then it will be a fresh... whatever.  In this case, a fresh MainTank!

I'm still got a bit of cheating on the Slime targeting the MainTank, with a MainTank named character node needing to be in the main game scene... which I can solve when I start making Character_Lists for the GameManager and each chacter.  They will use that info to pole the Main Tank instead...  another day.  Literally.


Big takeaway.... I got the Item / Type interface going.  I technically am meeting the Game Jam theme at one week in. Feels like a milestone!

Get Guildies

Leave a comment

Log in with itch.io to leave a comment.