physics.groups
function#The names of the Collision Groups of the place.
for _, group in physics.groups() do print(group) endUse it forreading the Collision Group names you set up in Studio.
Explosions, constraints, collision groups
local physics = require("@usbx/physics")The names of the Collision Groups of the place.
for _, group in physics.groups() do print(group) endUse it forreading the Collision Group names you set up in Studio.
Whether parts of the two Collision Groups collide.
if physics.collides("Ghosts", "Walls") then print("ghosts are blocked") endUse it forchecking whether two groups, like ghosts and walls, bump into each other or pass through right now.
aA Collision Group.bAnother Collision Group.Lets parts of the two Collision Groups collide or not. Players keep their own row of the matrix.
physics.set_collides("Ghosts", "Walls", false)Use it forletting ghosts pass through walls, or making a wall solid again once a round starts.
aA Collision Group.bAnother Collision Group.collideTrue lets their parts collide, false lets them pass through.Pushes Dynamic Parts and players away from a point, and damages the players. Force, damage and the push fall off to 0 at the radius.
physics.explode({ position = door.position, radius = 10, force = 500, damage = 30 })Use it forblowing up a bomb or rocket, which pushes nearby players and loose parts away and can hurt players.
optionsWhere the blast is, how far it reaches and how hard it pushes.explode callposition · radius · force · damage · players · effectpositionrequiredWhere the middle of the blast is in the world.
radiusrequiredHow far the blast reaches in studs, though the explosion players see is at most 80 studs.
forcerequiredHow hard the blast pushes things at its middle.
damagedefault 0How much damage players take at the middle of the blast.
playersWhether the blast pushes and damages players, which it does by default.
effectWhether players see an explosion, which they do by default.
Links two parts or models with a Constraint and returns it. Without anchor_b or face_b, anchor B goes where anchor A is now, except for a rope or a spring, which keeps it at the centre of b.
local hinge = physics.constrain({ type = "hinge", a = door, b = frame, face_a = "left" })Use it forhanging a door on a hinge, or tying a swing to a beam with a rope.
optionsThe type of joint, the two parts and its settings.constrain calltype · a · b · name · visible · anchor_a · 15 moretyperequiredWhat kind of joint the constraint makes between the two parts.
arequiredThe first part or model the constraint joins.
brequiredThe second part or model the constraint joins, which must not be the same as a.
nameThe Script Name to give the constraint.
visibleWhether players can see the constraint, which they can by default.
anchor_aWhere the constraint holds a, given as a point in the space of a.
anchor_bWhere the constraint holds b, in the space of b, which by default is where anchor A is now, or the centre of b for a rope or spring.
face_aThe face of a that anchor A is placed on.
face_bThe face of b that anchor B is placed on.
offset_aHow far to move anchor A from the centre of face_a.
offset_bHow far to move anchor B from the centre of face_b.
axisThe axis a hinge turns on or a slider moves along, which points straight out of face_a by default.
limits_enabledWhether lower_limit and upper_limit are used to hold it in range.
lower_limitThe lowest angle or position allowed, which must not be above upper_limit.
upper_limitThe highest angle or position allowed, which for a ball socket is the angle of its cone.
motor_enabledWhether a motor drives it, turning a hinge or sliding a slider.
motor_speedHow fast the motor turns or slides it.
motor_max_forceThe most force the motor is allowed to use.
lengthHow long a rope or spring is, which is the distance between the anchors by default.
stiffnessHow hard a spring pulls, so a higher number makes it stiffer.
dampingHow quickly a spring settles, so a higher number calms it down faster.