Skip to reading
The Sock Exchange, Part 3: The Dryer Conspiracy

Choose the walk as Bea moves

Edition 0.86.4.2

0.86.4.2 edition with appended native sprite-motion lessons. Earlier chapters, reference counts and screenshots retain their original edition context.

Download PDFView illustrations

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.

Code example
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

Page 15 of 18Permalink
Go to page

Continue your 2D adventure

  1. Part 1The Sock Exchange, Part 1: Your First 2D Adventure
  2. Part 2The Sock Exchange, Part 2: The Missing Laundry
  3. Part 3The Sock Exchange, Part 3: The Dryer Conspiracy
  4. Part 4The Sock Exchange, Part 4: Trouble After Closing
  5. Part 5The Sock Exchange, Part 5: The Midnight Pickup
  6. Part 6The Sock Exchange, Part 6: Closing Time