Godot Learning - Part 1
I’m learning how to use the Godot game engine and so I’m going to start keeping my notes on my blog so I can remember them, and hopefully gather resources that may help you.
My goal is to rebuild an ancient RPG I made called Final Existence on the Amiga in AMOS Basic, which was a YA alternate universe apocalyptic game that looked and felt a lot like Chrono Trigger. I’ve become a bigger fan of ARPGs lately, and I’ll rebuild it using that paradigm.
There are a crap ton of tutorials out there, but I’ve been having trouble gathering all the pieces I want together to build an ARPG, and there’s a lot of moving parts in Godot, so this is my attempt to wrangle all that together in one place for myself.
So, on with the notes:
What do I (think I) need next?
Area2Dcollisions for making the character walk around and get stopped by things, and know what I ran into.
- A map that’s bigger than the screen that follows the character around.
What have I found?
- Started with Your First Game to get a handle on editor in general
- GDScript is very Python-y, which is not my strongest language, but I’m getting the hang of it
- I wish Godot had vim keyboard shortcut support
- Learned TileMap and TileSet because I plan on using tiles to make maps
- Still need to figure out how to get things to run into tiles
- Walked through Kinematic Character 2D
- Watching Top-down RPG/Adventure in Godot
- i18n in Godot
- Looks like gettext
- Switch scenes via “NPC” with a Screen Change custom event
export varto select target scene
export varfor warp target in other scene
- Remove old scene from DOM
Scene#queue_freeto safely remove from memory!
- Add new scene to DOM
- Find player in new scene
- Move to position of warp target
- Put nodes into a group called “exit” to focus the search
- Dialog box
- Move it out of the way if the character is there
- The scene will need a camera
- Find the Camera2D
- Only one camera in a scene, pick one using
- Put the camera in the thing that needs to be tracked
- Drag margins require tracked object to hit edges before moving
- Make the camera current, or nothing will move
- Clamp the camera scroll to the size of screen with
- Grab the dimensions of something that’s as big as the scene
- Can you get scene/child node offset size
- Player move from scene to scene
- Primarily to transfer player state
- Video shows physically moving player node, since Player object contains state, but I’m thinking to have a Vuex/Redux like store external to visual scenes where such data can be stored and reconstituted
- Moving nodes from Scene to Scene seems error-prone, more reason for external state
- Like Ruby meets C?
- Using separate TileMaps
- One for walkable areas, one for collisions, one for stuff outside the play area
- Emit a signal on transport to recalculate camera clamping
Solution to “RPG Map with tiles and doors”
MapContainercontains the first
Playerhandles own position, using
move_and_collideto detect collisions, and
move_and_slideto complete moves after initial collisions.
Nodeand determines if it is a
Dooris a subclass of
KinematicBody2Dwith the exported properties
DestinationScenePath : Stringand
ExitID : int.
- On collision,
Playeremits a signal with
Mainlistens for collision signal from
Playerand, once received, manually swaps out the old map in
MapContainerwith the loaded
- …then searches the new scene for nodes in the
exitgroup and finds a node in that group with an
ExitIDproperty that matches the one received in the signal. If found, move
Map2have nodes in this order:
Doors with appropriately set
Wallswith tiles with
ExitNodes, each in the
exitgroup and with an
ExitIDthat matches the
Doorfrom the other scene.