Log inGet started
World

Excavator Sim — dig, load, haul

Branchmain
Branchesmain
Commit5227986045

README.md

ExcavatorController

One operator, one tracked excavator. Attached by scenes/main.scene/build.luau to the PlayerPrototype's body, so every joining player gets their own machine and the engine's multiplayer rules hold.

What it does

JobHow
TravelPoses the chassis — writes its position and yaw each tick.
The armPoses boom, arm and bucket as kinematic child entities from three angles.
HydraulicsPoses each ram between two anchors every tick, because a ram is rigid and the span is what moves.
DirtFills the bucket when its cutting edge is inside the heap, empties it over the tipper's bed.
The tipperRaises the bed when full, resets the load, counts what has been hauled away.

Why the machine's pose is written rather than forced

The body is a player's avatar, and the engine drives a player body from the entity's transform: a velocity or an impulse written to it is accepted and then discarded, because the transform is what the body is posed from. So this component integrates the machine's motion itself and writes the pose — which is also how the engine's own CharacterController moves a player.

The rigid body and its collider stay on the chassis, so the machine is still a solid thing other bodies meet and a query can find. Because nothing in the solver holds it back, the step it is about to take is cast first (clearance): six rays from the front of the shell, and the step is shortened to the first thing it would run into. A tracked machine is stopped by what is in front of it, and the stop has to be found before the step rather than after it.

The rig it needs

By name, under the body it sits on:

  • rig — everything visual, dropped so the tracks' soles are at the body's centre minus 0.86 (the collider's own floor)
  • house, boom_pivot, arm_pivot, bucket_pivot — the joint chain
  • bucket_point — where the bucket's cutting edge bites
  • dirt_load — the dirt drawn in the bucket
  • boom_ram_barrel / boom_ram_rod, arm_ram_barrel / arm_ram_rod

The joint angles and the reach every anchor is measured from come from Construction.RIG, so the geometry the scene build makes and the movement this component drives cannot drift apart.

By name, in the scene: dirt_heap, dirt_clump_1..3, truck_bed, truck_bed_load, truck_bed_point.

Controls

ExcavatorControls.inputMap: throttle (W/S), steer (A/D), slew (Q/E), boom (up/down), arm (left/right), bucket (Z/X) — each carrying keyboard, gamepad and touch.

Related

  • Hud — reads this component's published fields and shows them.
  • types/component, scenes/player-setup — the shape this follows.