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
| Thing | Module |
|---|---|
| Crates, debris, anything that tumbles | box3d |
| Cars, trucks, jeeps | box3dvehicle |
| People, mechs, monsters, anything that walks | walker |
| Planes | flight3d |
| A body gone limp | ragdoll3d |
| A shot along a line | hitscan3d |
| Rockets, shells, grenades, missiles | volley3d |
| A limb shot off | dismember3d |
| A spot behind cover | cover3d |
| A body getting into a car | interact |
solids only draws still models and makes nothing solid to any of these.
Giving each module its world
- For each module the scene lists, name its providers in
world.<module>.modsof the scene file. A slot takes one plugin, except box3d'spropsandkinds, which take a list. - Name terrain3d for the ground: walker's
height,depthandcell, box3d's, hitscan3d's and flight3d'sground, box3dvehicle'sland,gripanddrag, and ragdoll3d'sland. - Name scatter3d for trees and rocks: walker's, hitscan3d's, ragdoll3d's and cover3d's
solids, and box3d'sprops. - 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'sshootandbodies, and in box3dvehicle'sbodiesandstrike, so rounds and cars hit what a shot hits. - For cars, name box3dvehicle in
world.box3d.mods.kindsand box3d inworld.box3dvehicle.mods.gravity. For ragdolls in box3d, add ragdoll3d toworld.box3d.mods.kindsand setworld.ragdoll3d.physics. - Have a rule write the ground chunks box3d holds,
ground: [[i, j], …]on thebox3drow, each step. box3d builds no chunk by itself, and itspropscome only with chunks.
Two things in one slot
- Write a plugin of the game's own,
<a>, whose mod for the module,games/<game>/plugins/<a>/<a>.walker.tsfor walker, answers its own things and hands every other question to the plugin its own mods name. - Name it in the module's slot and the old provider in its own:
world.walker.mods.height: "<a>"withworld.<a>.mods.height: "terrain3d". - List
<a>inworld.shipped.plugins, so its mods are looked for in the game's folder.
Making something solid
| It must | Module | Through |
|---|---|---|
| Hold a walking body up: a floor, a deck, a ramp | walker | height, chained with terrain3d's |
| Stop a walking body sideways: a wall, a pillar | walker | solids circles |
| Stop a shot or a round | hitscan3d | solids cylinders with base and tall, or ground for a floor or a roof |
| Be hit and hurt | hitscan3d | bodies, and a hit act on its kind |
| Carry or stop a box3d body or a car | box3d | static, props, or a row of a static kind |
| Be landed on by a plane | flight3d | ground |
| Catch a limp body | ragdoll3d | land and solids, or box3d in the physics mode |
| Hide a bot | cover3d | solids |
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
- Give every kind that can be hurt one
hitact, which a shot, a round's splash, a car and a rule's burst all call (see hitscan3d). - 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. - List each kind a shot may hit in
world.hitscan3d.kinds, with the field that turns a dead bodyoff.
The same on every machine
- Compute every rule and every server mod with math's functions, never
Math.sinand its kind, since node and the browser differ in the last bit. - Make a mod's answer depend on
walone, never on a variable a second world would share.
Checking it
- Walk a body into every wall and onto every floor, shoot every structure, and drive a car into it.
- Test each mod the game adds beside it, as
<a>.<module>.test.ts, booting a scene that names it, and run it alone withyarn vitest run <file>.