Skip to content

Add transformer mode: car unfolds into a shell-firing mech#2

Open
Makio64 wants to merge 5 commits intomrdoob:masterfrom
Makio64:feature/transformer-mode
Open

Add transformer mode: car unfolds into a shell-firing mech#2
Makio64 wants to merge 5 commits intomrdoob:masterfrom
Makio64:feature/transformer-mode

Conversation

@Makio64
Copy link
Copy Markdown

@Makio64 Makio64 commented Apr 20, 2026

Depends on #1 (turtle shell / NPC racing). While #1 is open the diff shows both features; it will narrow automatically once #1 merges.

Summary

  • Press T (or gamepad B/circle) — the car performs a staged mechanical transformation into a stationary mech that rapid-fires shells from shoulder cannons.
  • Press T again to reverse. In robot mode the car can't drive — only aim and shoot.
  • Built on the shell + NPC systems from PR Add throwable turtle shell and NPC racing opponents #1 (same Shell projectile, HitFX, contact listener, spin-on-hit).

The transformation

Staged choreography driven off a single progress value (0.9 s forward, 0.7 s reverse):

Phase Action FX
0.00–0.10 Anticipation Car dips, wheels tuck in Camera shake starts
0.10–0.30 Liftoff (overshoot) Body rises, wheels hide, four chrome pods splay outward, underside plates explode out Shockwave ring, steam puffs, CLUNK
0.30–0.55 Torso deploy Spine extrudes, chest plate swings forward, back plate hinges up, blue core light ramps on Cyan electric arcs between shoulder hinges, servo whine
0.55–0.75 Head + arms Head slides up with overshoot, visor rotates open revealing red eye (flickers on), shoulder cannons unfold from folded-back to forward-ready Steam puff, screen flash, CLACK
0.75–0.90 Pose Cannons settle with spring oscillation, antenna pops up with overshoot, core flashes bright Big shockwave, 18% white flash, gold star burst

Robot mode

  • Physics body becomes MotionType.KINEMATIC, pinned at entry position, zero velocity.
  • A / D: rotate torso yaw (turret swings, cannons follow).
  • W / S: tilt cannon pitch ±14°.
  • Space: rapid-fire shells at 0.12 s cooldown, max 12 active, alternating left/right cannon tips.
  • Each shot: cannon recoils back 0.25 rad with spring-damped rebound; muzzle flash core + camera-facing flare at the tip; eye visor pulses brighter; cannon muzzle glows orange as heat accumulates (decays over 0.9 s).
  • Idle torso bob when fully transformed.
  • vehicle.stun() is a no-op during transform/transformer mode — robot is bullet-proof against its own ricochet.

File changes

  • New js/Robot.js — procedural mech hierarchy (~25 meshes, 6 shared materials) + choreographed per-phase animation + getCannonTransform(side) helper.
  • New js/TransformFX.js — pooled steam puffs, electric arcs (BufferGeometry Lines with jittered path), shockwave rings, and a camera-facing fullscreen white flash.
  • New js/MuzzleFlash.js — pool of 8 cannon-tip bursts (orange core + billboarded flare).
  • js/Vehicle.js — transform state machine, phase-cross FX triggers, kinematic swap, wheel hide / body raise during transform, turret input, camera-shake amplitude.
  • js/Controls.js — rising-edge transform flag (KeyT + gamepad button 1).
  • js/main.js — wire Robot + TransformFX + MuzzleFlash, route fire to cannon tips in robot mode, apply camera-shake post-offset.

Test plan

  • Serve statically (python3 -m http.server 8000), open http://localhost:8000/.
  • Normal drive works: shells, NPCs racing, HitFX on truck hits (all PR Add throwable turtle shell and NPC racing opponents #1 behaviour).
  • Stop, press T: full staged sequence plays — car dips, body rises with overshoot, wheels hide, pods splay, spine extrudes, chest swings, back plate flips, head pops up, visor opens flickering, cannons unfold, final shockwave + flash + stars.
  • Idle robot: torso bobs, blue core pulses, red eye glows steady.
  • Hold Space in robot mode: alternating L/R cannons rapid-fire, recoil + muzzle flash each shot, muzzles heat up orange.
  • A/D swings turret; shells fire along the new aim direction.
  • W/S tilts cannons slightly.
  • Press T again: reverse sequence runs faster, wheels re-appear, driving resumes normally.
  • Transform mid-roll: car snaps to full stop, transforms, reverts — no drift after restore.
  • Console clean, pool counts stable after multiple cycles.

🤖 Generated with Claude Code

Makio64 and others added 5 commits April 20, 2026 09:35
- Press Space (or gamepad A) to throw a bouncy turtle shell projectile that ricochets off walls and knocks trucks into a spin
- Convert the three static NPC trucks into kinematic waypoint-following racers looping around the outer track
- Shell hit spins target ~22 rad/s for 2.2 s with vertical hop and tilt wobble; ricochet also stuns the player
- Hit burst effect: expanding yellow ring plus pooled gold stars with gravity

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Press T (or gamepad B) to run a staged choreography: anticipation dip, body liftoff with overshoot, spine extrude, chest swing, head slide-up, visor flicker open, shoulder cannons unfold, final pose snap
- Physics body swaps to KINEMATIC during transform so the vehicle freezes in place; reverse transform restores DYNAMIC
- In robot mode A/D rotates the torso turret, W/S tilts cannon pitch, Space rapid-fires shells from alternating cannon tips at 0.12 s cooldown (max 12 active)
- Each shot recoils the cannon, pulses the red eye visor, and heats the muzzle tip toward orange glow
- Transform FX: staged shockwave rings, steam puffs, cyan electric arcs, yellow screen flash, camera shake, and Mario-Kart-style star burst on the final pose
- Procedural mech built from shared chrome / dark panel / yellow / blue-core / red-emissive materials to keep draw calls low

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Shells now carry a power multiplier; robot cannons fire at power=1.4 for ~30% longer stun, stronger spin, and a knockback that shoves the hit target along the shell's travel direction
- Targets on impact: NPCs slide in the impact direction with decaying velocity (kinematic body + mesh kept in sync); the player gets a linear-velocity impulse plus a small vertical lift
- Shell.onContact passes an impact vector { dirX, dirZ, power } built from the shell's current velocity so hits from any angle push correctly
- Recolor the mech primary body to the truck yellow with darker yellow trim so the robot reads as a transformed version of the player's vehicle

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Turret yaw rate: 2.5 → 5.0 rad/s for snappier aiming
- Max concurrent robot-mode shells: 12 → 24 so a sustained barrage stays uninterrupted

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Zero turretYaw / turretPitch at the start of each forward transform so the tower always deploys pointing the same direction as the car, instead of remembering the last aim.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mrdoob
Copy link
Copy Markdown
Owner

mrdoob commented Apr 22, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants