Choose the walk as Bea moves
TUTORIAL 03 • DIRECTION + DEPTH
The Sorting Room uses Part 2’s flat world stage. A short GDScript reads which way Bea is moving and makes her a little smaller at the back. The inventory puzzle works on its own if you stop before this page.
1 Under Scripts, add a GDScript named sorting_motion. Turn on Keep global instance alive. In the code area, replace the starter function with the block below. Keep its indentation. Click Validate, then Apply Changes and save. The global instance checks movement each frame on its own.
func _process(_delta):
if not is_instance_valid(Runtime) or Runtime.scene_id != "sorting_room":
return
var a = Runtime.player
if not is_instance_valid(a):
return
var s = a.get_node_or_null("Stage2DSprite")
if s == null:
return
var depth = clampf((a.position.z + 2.0) / 6.0, 0.0, 1.0)
a.scale = Vector3.ONE * lerpf(0.65, 1.0, depth)
var v = a.velocity
if absf(v.x) + absf(v.z) < 0.05:
return
var pose = "walk"
if absf(v.z) > absf(v.x):
pose = "walk_front" if v.z > 0 else "walk_back"
if s.sprite_frames.has_animation(pose):
s.flip_h = pose == "walk" and v.x < 0
if s.animation != pose:
s.play(pose)2 In play, select Walk and click clear floor just right of the shelf. As Bea heads up the screen, you see the back of her cap. Click the foreground directly below her and you should see her face. Click far to one side and you get the Part 2 side walk.
Same camera and crop size. At left, Bea has reached the rear aisle. At right she stands near the player. Compare the cap and coat against the same amount of picture space.
How the size works At world Z −2, Bea is 65% of her full size. At Z 4, she is full size. Positions between those two use an in-between size. The room ID at the top limits this effect to the Sorting Room.
PCA 3D Adventure Studio / 15
