Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

Bob

Bob rises an entity above where it rests and back down, once every seconds. It applies as a difference from its last offset, so it rides on whatever else moves the entity, a kinematic body’s next pose included.

Its props are in BobProps.

On an entity with a kinematic body, Bob raises the body through its next pose, as setNextPose does, so it pushes what it meets and carries what stands on it. On a fixed or a dynamic body it throws in development, naming the entity, since a fixed body never moves and a dynamic one is the solver’s: make the body kinematic, as the example’s coin does.

The room and every page. On an entity the room streams, the room raises it, a kinematic body with it, and each page draws the pose the stream brings. On an entity only a page holds, that page raises it.

The example template’s coin turns with Spin and rises with Bob, on a kinematic body:

games/example/src/components/Coin.tsx
import {
Bob,
box,
Entity,
Pickup,
type Position,
RigidBodyType,
sounds,
Spin,
} from "@spawnite/engine";
/** One coin: it turns, bobs, and goes into the wallet of whoever reaches it,
* with a chime.
* Its body follows the bob, so the ball bounces off it where it is drawn. */
export interface CoinProps {
position: Position;
}
export function Coin({ position }: CoinProps) {
return (
<Entity
position={position}
body={{ bodyType: RigidBodyType.Kinematic }}
collider={{ shape: box({ size: [0.8, 0.1, 0.8] }) }}
>
<Spin speed={2} />
<Bob height={0.2} />
<Pickup reward={1} sound={sounds.pickup} />
<mesh>
<cylinderGeometry args={[0.4, 0.4, 0.1, 24]} />
<meshStandardMaterial color="gold" />
</mesh>
</Entity>
);
}