Making a game

3D physics

Which plugin moves or tests a 3D thing, and how to make a thing solid to each.

Five modules move things in 3D and three test lines and places, each with its own model. Each is handed the world it moves in, the ground, what stands in the way and what can be hit, through its mods, so a thing is solid to a module only when a mod hands it to that module. Solid to one is not solid to another.

What moves the thing

ThingModule
Crates, debris, anything that tumblesbox3d
Cars, trucks, jeepsbox3dvehicle
People, mechs, monsters, anything that walkswalker
Planesflight3d
A body gone limpragdoll3d
A shot along a linehitscan3d
Rockets, shells, grenades, missilesvolley3d
A limb shot offdismember3d
A spot behind covercover3d
A body getting into a carinteract

solids only draws still models and makes nothing solid to any of these.

Giving each module its world

  1. For each module the scene lists, name its providers in world.<module>.mods of the scene file. A slot takes one plugin, except box3d's props and kinds, which take a list.
  2. Name terrain3d for the ground: walker's height, depth and cell, box3d's, hitscan3d's and flight3d's ground, box3dvehicle's land, grip and drag, and ragdoll3d's land.
  3. Name scatter3d for trees and rocks: walker's, hitscan3d's, ragdoll3d's and cover3d's solids, and box3d's props.
  4. Name the bodies a shot hits in hitscan3d's bodies: walker's upright cylinders, ragdoll3d's bone capsules, or dismember3d's joints. Name hitscan3d in volley3d's shoot and bodies, and in box3dvehicle's bodies and strike, so rounds and cars hit what a shot hits.
  5. For cars, name box3dvehicle in world.box3d.mods.kinds and box3d in world.box3dvehicle.mods.gravity. For ragdolls in box3d, add ragdoll3d to world.box3d.mods.kinds and set world.ragdoll3d.physics.
  6. Have a rule write the ground chunks box3d holds, ground: [[i, j], …] on the box3d row, each step. box3d builds no chunk by itself, and its props come only with chunks.

Two things in one slot

  1. Write a plugin of the game's own, <a>, whose mod for the module, games/<game>/plugins/<a>/<a>.walker.ts for walker, answers its own things and hands every other question to the plugin its own mods name.
  2. Name it in the module's slot and the old provider in its own: world.walker.mods.height: "<a>" with world.<a>.mods.height: "terrain3d".
  3. List <a> in world.shipped.plugins, so its mods are looked for in the game's folder.

Making something solid

It mustModuleThrough
Hold a walking body up: a floor, a deck, a rampwalkerheight, chained with terrain3d's
Stop a walking body sideways: a wall, a pillarwalkersolids circles
Stop a shot or a roundhitscan3dsolids cylinders with base and tall, or ground for a floor or a roof
Be hit and hurthitscan3dbodies, and a hit act on its kind
Carry or stop a box3d body or a carbox3dstatic, props, or a row of a static kind
Be landed on by a planeflight3dground
Catch a limp bodyragdoll3dland and solids, or box3d in the physics mode
Hide a botcover3dsolids

The numbers of a shape, a floor's rectangle and top or a wall's circles, belong in the definition of the kind whose row stands there, in its own frame, placed by the row's pos and yaw. Measure a floor's top from the model, so a body stands on the floor that is drawn.

Hurting what is hit

  1. Give every kind that can be hurt one hit act, which a shot, a round's splash, a car and a rule's burst all call (see hitscan3d).
  2. Hand each shot and each fired round its hurt, { damage, by }, the damage a number or a number for each part a shot can meet. A round that splashes takes a number.
  3. List each kind a shot may hit in world.hitscan3d.kinds, with the field that turns a dead body off.

The same on every machine

  1. Compute every rule and every server mod with math's functions, never Math.sin and its kind, since node and the browser differ in the last bit.
  2. Make a mod's answer depend on w alone, never on a variable a second world would share.

Checking it

  1. Walk a body into every wall and onto every floor, shoot every structure, and drive a car into it.
  2. Test each mod the game adds beside it, as <a>.<module>.test.ts, booting a scene that names it, and run it alone with yarn vitest run <file>.