-
Notifications
You must be signed in to change notification settings - Fork 0
Setting Up the Godot Scene
Now for the part that actually gets your assets in the game.
I will be assuming you have at least partially finished the Blender part. Your art or animations do not need to be fully complete yet, but you should have at least:
- a
.glbexport from Blender - a basic rig
- at least one animation, ideally
idle
You technically can use the imported .glb model directly, but I do not recommend it. It is better to separate the imported model from the scene you actually edit, otherwise things can break or get reset when you re-import the model.
Because of that, we will make an inherited scene first.
Find your .glb file in Godot:
- Right-click the
.glbfile. - Pick
New Inherited Scene. - Save it as something like
myCharacter_imported.tscn.
Now make another scene that will act as the actual 3D character view:
- Create a new 3D scene.
- Drag
myCharacter_imported.tscninto its root node. - Right-click the imported scene instance and enable
Editable Children. - Add an
AnimationTreenext to theAnimationPlayer. - Add a
Camera3D. - Set the
Camera3Dprojection toOrthogonal.
You can save this scene as something like myCharacter_view.tscn.
This scene is the 3D model/camera setup that will later be rendered into the 2D character scene.
When re-importing the .glb, Godot may not always update everything correctly. This should not permanently break anything, but sometimes parts of the model or animations may look mangled.
If that happens:
- Double-click the
.glbfile. - Open the import settings.
- Click
Reimport.
This is also where you can set animations as "looping". Its relevant for your idle. On the left side scroll down untill you find the animation, click it and set it to loop.
Now we will set up the actual character/enemy scene.
If you already have a working placeholder scene, you can probably skip this part and just adapt it.
Otherwise, make a new 2D scene with this structure:
-
Root-Node2D-
Visuals-Node2D -
Bounds-Control -
IntentPos-Marker2D -
CenterPos-Marker2D -
OrbPos-Marker2D -
TalkPos-Marker2D
-
The exact names matter, because the game expects certain nodes to exist.
Roughly speaking:
-
Visualscontains the visible character setup, you can put whatever you want in here. -
Boundscontrols the targetable area and HP bar. -
IntentPosis where enemy intent icons appear. -
CenterPosis the center used for some random things like VFX. -
OrbPosis used for orb positioning. -
TalkPosis used for talk bubbles.
You will probably need to adjust these markers later so they line up nicely with your character.
This is the part that lets you render the 3D character scene as a 2D image inside your normal 2D character scene.
Inside your Visuals node, create this setup:
-
Visuals-
CharBox-Control-
SubViewportContainerSubViewport
-
-
Then configure the SubViewportContainer:
- Enable
Stretch. - Set layout mode to
Anchors. - Set anchors preset to
Full Rect.
Now drag your myCharacter_view.tscn scene into the SubViewport.
Lastly in the SubViewport toggle Own World 3D, by default ViewPorts share the same world, but that would lead to jank with multiplayer. This fixes that.
Also enable Transparent BG
The final structure should look roughly like this:
-
Root-
Visuals-
CharBox-
SubViewportContainer-
SubViewportmyCharacter_view
-
-
-
BoundsIntentPosCenterPosOrbPosTalkPos
-
Assuming nothing went wrong, you should now see your character in the scene.
If the character is not visible, check:
- the
Camera3Dis looking at the model - the camera is set to
Orthogonal - the model is inside the camera view
- the
SubViewportContainerhas a visible size - the
SubViewportis inside the container - the 3D scene is actually inside the
SubViewport
The AnimationTree is used to control animation playback.
The exact setup depends on how your character scene and code are structured, but the basic idea is:
- Add an
AnimationTree. - Assign the correct
AnimationPlayer. - Enable the
AnimationTree. - Set up the animation state machine.
Transitions going from idle
- Reset -
On - Switch Mode -
Immediate - Advance Mode -
Enabled
Transitions going toidle
- xFadeTime (optional)
- Reset -
On(optional) - Switch Mode -
At End - Advance Mode -
Auto
At minimum, you probably want your idle animation to play correctly first. Once idle works, test attack, cast, hurt, and die.
If animations do not play:
- check that they imported from Blender
- check that the names are correct
- check that the
AnimationTreepoints to the rightAnimationPlayer - check that the animation is not accidentally empty
- check that looping is enabled for idle in the import
Once the scene looks correct in Godot, test it in-game as early as possible.
Do not wait until every animation is finished.
A good first test is:
- the character loads
- idle animation plays
- the model is positioned correctly
- target/bounds feel reasonable
- attack or cast animation can play
- nothing explodes
A rough model that works in-game is much more useful than a polished model that doesnt.