Gamejam Devlog - Timedust v0.0.9 - Basic Enemy


A few words about the only enemy of the game, a basic slow worm enemy, that only moves horizontally, and switches direction when it hits a certain area.

I used two Area2D for along with a RayCast. Now, I remember that for Moonie, I used the levels walls to act as movement limiters however, this solution has its limits: the nme must be between two walls for the raycaast to trigger.
So as I want Timedust to be more aerial, monsters will not be always enclosed between walls. I pretty sure there is a better way to do this, but I eventually manage to make it work and, in the context of the gamejam, I didn't have a lot of time to think about this.

Timedust devlog enemy

Area2Ds serves to decide when the mob will switch direciton

As a sidenote, I think using simple Position2D nodes could do the trick, without having to use Raycasts. We would need to test if the actor's position is greater or smaller than the corresponding points. We would use dir to define if yes or no the mob switches directions.
* I need to try this next time *

Our monster has a variable that is used to define which direction it's facing ( the Player is made the same way). dir will always be 1 or -1 so I can use it to test various situations, or to use it as a multiplier (or negative multiplier) to set variables depending of the direction it's facing. ie: flipping the animated sprite

As soon as the RayCast hits an Area2D, it switches dir to it's opposite value. Then dir is used to multiply the casting direction : if it's positive, the RayCast will cast towards the right, if it's negative, it will cast towards the left!

The Areas2D are part of the enemy itself. However, it means that in the world level, the enemies won't possibly be instanciated. Indeed, in order to adjust the monster's trajectories so that they could answer to the level design needs, each monster has to be unique.

I didn't realize it at the time of the jam, but this si the biggest flaw of this solution. I then choose to live with it and move on to other part of the game.

Timedust flipping direction AI

I use a variable dir to define direction


The right way to do this would be to create a bunch of dummy objects and each one of them will be assigned a direction. When an actor collides with the dummy, it will change direction accordingly. Then make the dummies objects invisible and we're good to go!
On the tech side, this should be achieved in Godot with the use of layers, or maybe even with getting the dummy object's name.
I'm seeing two way of doing this:
1- The directions changes are coded within the enemy script, and the change apply as soon as a collision with a specific dummy is detected.

2- This one may be a bit more complex, but also more modular: the dummy objects would contains certain infos like direction, speed, etc and would transfer those values to the actor it collided with. This could serve not only for enemy movement AI, but also for instant speed boosters (or higher jumping).

This is interesting, and I should explore that idea more in the future.

In any case, I am really curious to know what you, my readers are thinking! Don't hesistate to share your thoughts, and why not discuss alternatives solutions?

Cheers y'all!

Get Timedust - Jam Edition

Download NowName your own price

Leave a comment

Log in with to leave a comment.