Welcome to part 2 of this series!
Video 3 - Movement and collisions
Since I am progressing parallel to Heartbeasts videos I also end up adding the same bugs as him so we gotta fix them now
Next lets tackle collisions...
And here I thought just slapping a collision object onto both game objects was enough but turns out you also have to disable gravity and I opted to remove friction etc. from the player collision object since we do this ourselves:
I also moved the player to z-index 1 so that he does not get rendered behind the bush
The only missing part
And thats it for video 3!
Video 4 - Extract it into scenes and do the Y Sort
Video 4 extracts the player and the bush into scenes, so we will do something similar by extracting the bush and player game object.
That was the easy part, next we have to do Y-Sorting which... Defold does not seem to support out of the box :(
So we just implement our own really naive y-sort component/script which sets the current z coordinate of the associated game object to a value between 0 and 1
Video 5 - Animations
This mostly boiled down to playing the animations when the input vector is modified as unlike in Godot calling play animation repeatedly does not seem to work as expected in Defold as it replays the animation every time.
I also added a few more than I was supposed to do oups :).
Lastly when the character comes to a still stand we want to play the idle animation:
Video 6 - Animations in all directions without the animation tree :(
As Defold does not have a fancy animation tree we have to do this manually. First we need to capture the last look direction for that I created some helper functions into xvmath:
and added this function to the player controller:
And thats video 6!
Video 7 - Background Grass and the dirt path
This one starts super tricky as I can't just make a Sprite scale easily as the background image (as far as I can see) so instead I opted into using a Tilemap. This also brought with it another problem though as Defold only allows you to use images from a single tile source and therefore only a single image so I had to create a custom tile sheet to make this work!
Autotile is also not a thing in Defold so we have to create the paths manually. The tilemap is a lot more limited than expected so I'd probably recommend using Tiled or LDtk for this instead in a normal project. For this limited project we will try to make do with what we have though!
Next problem we can not really see what is on the layer without setting the Z index of the layer but even doing so does not really do anything while rendering...
Despite being visible in the editor
presumably this is a bug?
Either way with this we finish part 2 on a bit of a low note :(