Park another car
Goal
The hangout kit's street has a third car anyone can get into with E and drive, the same as the two it ships with. The cars are declared by where they are parked, so a new car is one more spot.
Files you will edit
src/street.ts
Steps
Add a parking spot.
CAR_SPOTSlists where each car stands on the floor plan,[x, z]in metres; every car is parked facing west. The street runs along X between the doors, andSTREET_BOUNDSkeeps a driven car insidexin -10..10 andzin -3..3, so park the new one there, clear of the others (a car is 3.8 m long).ts/** Where the cars are parked: on the street, facing west (yaw PI/2). */ export const CAR_SPOTS: readonly (readonly [number, number])[] = [ [-4, 0], [4, 0], [0, 2.2], ];Nothing else changes.
src/game.tsspawns oneSedanper spot, andsrc/props.tssizes the car lanes (pose, speed, driver) from the same list when it finds the cars ininit.Rebuild the guest, because Play Solo's authority runs it:
shnpm run build:guest
Verify
sh
npm testpasses as before. Then npm run dev, open http://localhost:5196, walk to the middle of the street: a third red car stands there, and next to it your HUD says E: drive. Press E and W: it drives off west.
See also
- Play with friends: two tabs in one room, so a friend can take the other car.
- Send a message: the pattern behind
sitandcosmeticin the kit'ssrc/messages.ts.