Stage 7 of 11
Leela's scene
By the end
robots/leela.tscn: a rigid body with a collider round her body, her model turned and scaled, her weight, her layers and her groups.- Leela in the playground, with the camera on her.
She has no script yet. When you run it she drops and stops with her legs sunk in the floor, and that's the right result.
Leela gets a scene of her own, so the main scene only has to place her. This stage builds it with no script at all, and what happens when you run it is worth seeing.
Her body
Scene → New Scene. Under Create Root Node: press Other Node and choose RigidBody3D. Name it
Leelaand save the scene (Ctrl+S) asres://robots/leela.tscn. The dialog already offersleela.tscn, from the root's name: openrobotsin it, then Save.A RigidBody3D is a body the physics engine moves: it has weight, it falls, and only forces move it. That's the point of the whole project, and stage 8 comes back to it.
- Add a CollisionShape3D under it and name it
Shape. (The name matters: stage 8's script asks for$Shape.) Set:
| Section | Property | Value | Why |
|---|---|---|---|
| Shape | New → CylinderShape3D, then inside it: | ||
| → Height | 0.67 | ||
| → Radius | 0.4 | Her knees and toes reach 0.37 to 0.40 m from her middle. At 0.3 they went into walls. | |
| Transform | Position | 0, 0.665, 0 | The cylinder then runs from 0.33 m up to 1.0 m. |
Her collider is only her body. It stops 0.33 m above her feet. Her legs have no collider at all: they'll hold her up by pushing, and the room under her is what lets her crouch, land and step over things.
- Select
Leelaand press the chain-link button at the top of the Scene dock. (Instantiate Child Scene... on a node's right-click menu is the same thing.) Select Scene lists the project's scenes: one click onLeela.blendpicks it. The new node arrives namedLeela2. Rename itModel. (This name matters too:$Model.) Set:
| Section | Property | Value | Why |
|---|---|---|---|
| Transform | Rotation | 0, 180, 0 | She faces +Z in her file. Forwards is −Z here. |
| Scale | 0.2, 0.2, 0.2 | 5.3 units tall becomes 1.05 m. Type it into x: the chain at the row's end keeps the three the same. |
Her feet are now at the scene's origin, and her collider is round her body.
Her weight
Select Leela and set:
| Section | Property | Value | Why |
|---|---|---|---|
| Mass | 30 kg | ||
| Physics Material Override | New → PhysicsMaterial, with Friction 0.2 | So her collider slides along walls and off edges and doesn't grip them. The grip that moves her isn't friction: it's a number in stage 8's script. | |
| Mass Distribution | Center of Mass Mode | Custom | So you say where her weight is. Left on Auto, it's the middle of the collider, and stage 8's script reshapes the collider. |
| Center of Mass | 0, 0.62, 0 | A little above her hips. The row shows once the mode is Custom. | |
| Inertia | 1.5, 1, 1.5 | How hard she is to turn about each axis. Fixed for the same reason. | |
| Deactivation | Can Sleep | Off | A body at rest "falls asleep" and the engine stops running it. Her legs are forces applied every tick: asleep, she'd never take another step. |
| Collision | Layer | 2 only (click box 1 off and box 2 on) | Layer 2 is "robots". |
| Mask | 1 and 4 (box 4 on as well) | What she bumps into: the level (1) and loose parts (4). |
Layers in this project. A body's layer says what it is, and its mask says what it bumps into.
| Layer | What's on it |
|---|---|
| 1 | The level. The only layer her feet's rays look for. |
| 2 | Robots. |
| 4 | Parts knocked off a robot. |
| 13 | The stairs' hidden smooth slope, for bodies that glide. Not for her. |
Her groups
With Leela selected, open the Groups dock and put her in two groups, making each with + as in stage 6:
outline, as the repo's Leela is. (You made a group of that name inmain.tscn. Groups made this way belong to their scene, so make it again here. The same name is the same group.)psx_character, which hands her materials toPsx(stage 6).
Save the scene.
Put her in the playground
- In
main.tscn, add a Node3D underMainand name itRobots. - Drag
leela.tscnfrom the FileSystem dock ontoRobots. Set the newLeela's Position to 1.4, 0.05, 4.6. (The repo's spot: 5 cm up, so she drops onto the floor.) - Select
Cameraand set its Target toLeelawith Assign.... - Delete
StandIn.
Checkpoint
Run it. Leela is a white statue, standing stiff, and she drops at once and stops with her legs sunk in the floor to above the knees. (Measured: she comes to rest 0.33 m down in half a second, upright.)
That's exactly right, and it's the picture to keep in mind for stage 8:
- She's white because her material isn't on her yet. Stage 9's script puts it on.
- She's stiff because nothing moves her bones.
- She's sunk because her collider is only her body. Her legs are just a picture so far. The floor stops the cylinder, 0.33 m up from her feet.
If not:
- She falls through the floor and away: her Mask hasn't got layer 1, or
Groundisn't a Block. - She's a giant:
Model's Scale. - She isn't there at all: the model didn't import (stage 2).