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?
TileMap/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
- The official docs
- Using KinematicBody2D on KidsCanCode
- Still think I’m missing something with this:
- Can’t quite get the character to walk/move as expected
- Also this is more platformer-y than I need right now
- 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 sceneexport varfor warp target in other scene- Remove old scene from DOM
get_tree().root.get_child()/.add_child()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
Camera2D#make_current() - 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
- Only one camera in a scene, pick one using
- Clamp the camera scroll to the size of screen with
Camera2D#limit_??- Grab the dimensions of something that’s as big as the scene
- Can you get scene/child node offset size
- Grab the dimensions of something that’s as big as the scene
- Move it out of the way if the character is there
- 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
- Primarily to transfer player state
- Crystal
- Like Ruby meets C?
- Using separate TileMaps
- One for walkable areas, one for collisions, one for stuff outside the play area
- Signals
- Emit a signal on transport to recalculate camera clamping
- i18n in Godot
Solution to “RPG Map with tiles and doors”
Node2DMainscene withKinematicBody2DPlayerandNode2DMapContainerMapContainercontains the firstMapPlayerhandles own position, usingmove_and_collideto detect collisions, andmove_and_slideto complete moves after initial collisions.Playergets collisionNodeand determines if it is aDoorDooris a subclass ofKinematicBody2Dwith the exported propertiesDestinationScenePath : StringandExitID : int.- On collision,
Playeremits a signal withDestinationScenePathandExitID
Mainlistens for collision signal fromPlayerand, once received, manually swaps out the old map inMapContainerwith the loadedDestinationScenePath…- …then searches the new scene for nodes in the
exitgroup and finds a node in that group with anExitIDproperty that matches the one received in the signal. If found, movePlayerto thatNode2D#position.
- …then searches the new scene for nodes in the
MapandMap2have nodes in this order:TileMapWalkable- Any
Doors with appropriately setDestinationScenePathandExitID TileMapWallswith tiles withCollisionenabledExitNodes, each in theexitgroup and with anExitIDthat matches theDoorfrom the other scene.