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
/Area2D
collisions 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 var
to select target sceneexport var
for warp target in other scene- Remove old scene from DOM
get_tree().root.get_child()
/.add_child()
Scene#queue_free
to 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”
Node2D
Main
scene withKinematicBody2D
Player
andNode2D
MapContainer
MapContainer
contains the firstMap
Player
handles own position, usingmove_and_collide
to detect collisions, andmove_and_slide
to complete moves after initial collisions.Player
gets collisionNode
and determines if it is aDoor
Door
is a subclass ofKinematicBody2D
with the exported propertiesDestinationScenePath : String
andExitID : int
.- On collision,
Player
emits a signal withDestinationScenePath
andExitID
Main
listens for collision signal fromPlayer
and, once received, manually swaps out the old map inMapContainer
with the loadedDestinationScenePath
…- …then searches the new scene for nodes in the
exit
group and finds a node in that group with anExitID
property that matches the one received in the signal. If found, movePlayer
to thatNode2D#position
.
- …then searches the new scene for nodes in the
Map
andMap2
have nodes in this order:TileMap
Walkable
- Any
Door
s with appropriately setDestinationScenePath
andExitID
TileMap
Walls
with tiles withCollision
enabledExitNode
s, each in theexit
group and with anExitID
that matches theDoor
from the other scene.