Gamejam Devlog - Timedust v0.0.7 - Remote Doors
When I was workingwith other engines (and other languages), I wondered hox I could obtain a remotely opened door, and I honestly was stuck at this point as my programming skills are limited.
However, thanks to Godot I had an idea. Before that, I was thinking the door and the button as two separate objects and how to make them communicate with one another. i'm pretty sure it's possible though, but i just don't know how (yet?)
Godot nodes system, is really cool because, as I was experimenting with the Area2D node, it came to me that the button would only be a trigger (which it actually is) that does not need to be separated from the door.
I made some tests with the button being an Area2D of a main object 2D node: the door itself and... it worked pretty perfectly!
Thus the Area2D detect the player and send the signal. The button'sprite change to the pressed state (boolean variabme), and, super easy, hiding/unhiding two Sprite2D nodes via their visible built-in property.
The pressed state triggers the door's opening animation which in turn deactivate the door collision, sothe player can pass.
I encountered 2 issues for which I had to find a workaround:
The door's collision disappears only when the door is fully open (at the end of its animation). Meaning that if the player is close enough, they will get stuck against the collision even if the door is semi-open, which would be counter intuitive. However, this issue happened while testing, and in a testing context, the button would be very close to the door for obvious practical reasons.
Workaround: It will never happen if the button is always far enough from the door, which makes perfect sense. It can't be a bug if it never happens, right ;)
An alternative solution would have to change the collision mask along the way, matching the door's sprite animation. As I was a bit rushing against time at that moment, I just kept it like that (I did it a few hours later with the animated spikes though).
As the door would be instanciated scenes linked to the world node of the level, I couldn't have more than 1 door per level: if I changed the position of the Area2D button, it would change it for every other instances. That would allow only 1 position for the button, and that wouldn't be very interesting gameplay wise.
Workaround: I just had to make the doors local to the scenes by unlinking them from the parent node, and it works like a charm.
On a side note, having the doors local to the level also allows me to change their scale (choosing which direction it faces) and orientation ( in order to have a door opening upwards, which would allow a cool double door variation)
I realized one last issue during the final tests, which I waived for the gamejam submission (same issue for the ennemies:
if the players dies and respawn after opening a door, said door remains open. I think I can fix that with the player sending info to the singleton which will reset the door at it's closed state.
This is something I will fix if I work further on the game.
Get Timedust - Jam Edition
Leave a comment
Log in with itch.io to leave a comment.