Physics3D
Make 3D Shapes
A box is a block. A sphere is a ball. A capsule is a pill shape. floor makes easy ground. static_box makes a block that cannot fall or move.
New to coding?
Copy the examples exactly first. Run them. Then change one number or word and run them again. You are not expected to memorize the command lists.
Shape commands
x, y, and z say where a shape lives. Width, height, and depth say how big it is. Radius says how far a round shape reaches from its center.
box(world, x, y, z, width, height, depth, mass=1)
sphere(world, x, y, z, radius, mass=1)
capsule(world, x, y, z, radius, height, mass=1)
static_box(world, x, y, z, width, height, depth)
static_sphere(world, x, y, z, radius)
static_capsule(world, x, y, z, radius, height)
floor(world, y=0)
plane(world, nx, ny, nz, offset)Push, move, and turn shapes
material changes bounciness and grip. set_position places an object somewhere. set_velocity makes it move. apply_impulse gives it one quick push. You can learn the turning commands later.
material(world, body, bounce, friction)
set_position(world, body, x, y, z)
set_velocity(world, body, vx, vy, vz)
set_rotation(world, body, pitch, yaw, roll)
set_angular_velocity(world, body, x_deg, y_deg, z_deg)
set_damping(world, body, linear, angular)
lock_rotation(world, body, locked=true)
apply_force(world, body, fx, fy, fz)
apply_impulse(world, body, ix, iy, iz)
apply_impulse_at(world, body, ix, iy, iz, world_x, world_y, world_z)
apply_torque(world, body, tx, ty, tz)
apply_angular_impulse(world, body, ix, iy, iz)Ask what happened
body_info gives you a dictionary full of facts about an object. Start with info["x"], info["y"], and info["z"] to learn where it is. The other helpers answer simple yes-or-no questions.
info = Physics3D.body_info(world, body);
Physics3D.is_colliding(world, body);
Physics3D.is_grounded(world, body);
Physics3D.is_sleeping(world, body);
Physics3D.contacts(world, body);
Physics3D.wake(world, body);
Physics3D.remove_body(world, body);