Skip to content
cccskills
FreePublished on GitHub

roblox-physics

Implement Roblox physics, collisions, and hit detection using forces, constraints, raycasts, and volume queries. Manage connected parts and network ownership, which determines who simulates objects, while addressing unstable motion, missed hits, and server validation of gameplay results.

OriginalShow the original description

Implement Roblox physical simulation and queries with assemblies, anchoring, constraints, collision groups, CanCollide/CanTouch/CanQuery, raycasts and overlap queries, mass, impulses, forces, velocity, moving assemblies, cleanup, and network ownership. Use for Roblox collisions, hit detection, RaycastParams, PhysicsService, projectiles, vehicles, knockback, constraints, deprecated BodyMovers, unstable motion, or client-owned physics exploits.

Works withX (Twitter)

Run score Not tested

See how to install

Good for

  • Implement server-side projectile and attack hit detection
  • Control vehicles and knockback with forces and constraints
  • Configure collision groups and query filters
  • Investigate jitter, missed collisions, and network ownership issues

Files included (3)

  • SKILL.md7.9 KB
  • agents/openai.yaml199 B
  • references/queries-and-ownership.md3.0 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Roblox physics

Choose deliberately between simulation, character control, hit detection, and visual-only motion; they are different jobs. Targets Roblox's rolling platform APIs. Pair with physics-tuning for engine-neutral stability and feel.

When to use

  • Use for BasePart assemblies, constraints, collision/query policy, ray/overlap queries, forces, impulses, moving physical objects, network ownership, or physics cleanup.
  • Use when Touched is unreliable/security-sensitive, parts tunnel or jitter, a mechanism breaks when anchored, or old BodyMover patterns appear.

When not to use: ordinary Humanoid lifecycle/control belongs to roblox-characters; remote validation belongs to roblox-networking; decorative UI/world motion may only need a tween.

Decide the system first

GoalMechanism
sustained physical interactionunanchored assembly + modern constraints/forces
instantaneous physical changeApplyImpulse / ApplyAngularImpulse
kinematic platform/pathcontrolled pivot/transform with an explicit passenger policy
character locomotionHumanoid/custom character controller (roblox-characters)
authoritative hit testserver raycast/overlap with filters and gameplay validation
cosmetic trail/recoillocal visual motion; no gameplay authority

Workflow

  1. Inspect the mechanism. In Studio, visualize assemblies, anchors, constraints, collision groups, massless parts, and network owners. Identify the assembly root and intended authority.
  2. Define interaction policy. Write the collision-group matrix and separately decide CanCollide, CanTouch, and CanQuery. These flags are not interchangeable.
  3. Choose simulation or query. Do not use .Touched as a universal hit detector. Use a ray for a path/line, an overlap query for a volume, and simulation contacts when physical response is actually required.
  4. Apply motion at assembly level. Forces on a part affect its assembly. Use modern LinearVelocity, AngularVelocity, VectorForce, AlignPosition, and AlignOrientation constraints as appropriate; migrate deprecated BodyMovers when changing that system.
  5. Set ownership deliberately. Server-own gameplay-critical loose assemblies when required; client ownership can improve responsiveness but never authorizes gameplay results.
  6. Bound cost and lifetime. Reuse query parameters, cap query frequency/result count, remove temporary constraints/attachments, and disconnect event listeners.
  7. Verify under load and multiplayer. Test anchored/unanchored transitions, mass extremes, collision matrix, fast motion, multiple clients, ownership changes, streaming, and cleanup.

Pattern: filtered server raycast

local Workspace = game:GetService("Workspace")

local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {shooterCharacter}
params.IgnoreWater = true
params.CollisionGroup = "WeaponQuery"

local direction = aimDirection.Unit * MAX_RANGE
local result = Workspace:Raycast(muzzlePosition, direction, params)
if result then
    local model = result.Instance:FindFirstAncestorOfClass("Model")
    local humanoid = model and model:FindFirstChildOfClass("Humanoid")
    if humanoid and serverCanDamage(shooter, model, result.Position) then
        humanoid:TakeDamage(serverWeaponDamage(shooter))
    end
end

The server must validate the origin/direction against server-known character/weapon state; do not accept an arbitrary client origin and treat the raycast itself as validation.

Pattern: overlap volume with explicit policy

local params = OverlapParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {sourceCharacter}
params.CollisionGroup = "DamageQuery"
params.MaxParts = 64

local seen: {[Model]: boolean} = {}
for _, part in Workspace:GetPartBoundsInBox(hitboxCFrame, hitboxSize, params) do
    local model = part:FindFirstAncestorOfClass("Model")
    if model and not seen[model] then
        seen[model] = true
        validateAndApplyHit(model)
    end
end

Bounds queries use bounding boxes and can include multiple parts from one target; deduplicate and perform exact/gameplay checks as needed. For exact geometry use WorldRoot:GetPartsInPart(part, overlapParams) only when its additional cost is justified. Note OverlapParams.RespectCanCollide decides whether a query honours CanCollide or CanQuery — set it deliberately, or it silently overrides the flag policy below. OverlapParams.Tolerance controls contact slop.

Assemblies, force, and ownership

  • Welded parts form one rigid assembly; force, impulse, velocity, mass, and ownership operate on that assembly. Anchoring a part changes simulation/ownership and can make an assembly effectively infinite mass.
  • Apply an impulse for a one-time change; use a force or velocity constraint for sustained control. Setting AssemblyLinearVelocity is an immediate state change, not a continuous force model.
  • Prefer attachments plus modern constraints over BodyPosition, BodyVelocity, BodyGyro, and other deprecated BodyMovers when authoring or revising a mechanism.
  • Automatic ownership may move nearby unanchored assemblies to clients. Use SetNetworkOwner(nil) conservatively for critical objects, then measure responsiveness/server cost. Visualize network owners in Studio.
  • A client owner can manipulate physical results and .Touched observations. The server validates consequential hits, positions, timing, and permissions independently.

Common failures

SymptomLikely causeRemedy
welded mechanism will not moveone part anchoredinspect full assembly; anchor only intentional world roots
force behaves too strongly/weaklyassembly mass ignoredinspect AssemblyMass; tune force/impulse by intended acceleration
hit misses fast projectilediscrete touch sampling/tunnelingswept query — WorldRoot:Blockcast(), Spherecast(), or Shapecast() — plus physics-tuning; do not rely only on .Touched
ray hits shooter/effectsfilters/collision group absentreuse explicit params and query group
same target damaged many timesoverlap returned multiple body partsdeduplicate by target model and enforce attack ID/cooldown
exploit fires impossible touchclient owns relevant physicsserver query/context validation; deliberate ownership
invisible trigger blocks or cannot querythree flags conflatedset CanCollide, CanTouch, CanQuery independently
mechanism leaks attachmentstemporary constraint lifecycle missingown and destroy constraints, attachments, and connections together

Resources

  • Read references/queries-and-ownership.md for collision/query matrices, assembly debugging, ownership security, migration choices, and the physics verification matrix.

Related skills

  • physics-tuning — timestep, jitter, tunneling, mass ratios, and stability methodology.
  • roblox-characters — Humanoid/custom movement and respawn lifecycle.
  • roblox-networking — authoritative validation of client-requested physical actions.
  • roblox-studio-workflow — visualization, Output, and multi-client verification.

Primary references

  • https://create.roblox.com/docs/physics/assemblies
  • https://create.roblox.com/docs/physics/network-ownership
  • https://create.roblox.com/docs/workspace/raycasting

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Implement reusable decision systems for game characters using behavior trees, which organize conditional actions, and Utility AI, which scores available choices. Build either approach or combine them to control patrols, combat, targeting, and needs-based behavior.

  • Build a reusable behavior tree runtime
  • Choose attacks or targets using action scores
  • Combine patrol and combat trees with Utility AI
gamedev-skills/awesome-gamedev-agent-skills3.7KUpdated Oct 23, 2026

audio-design

FreeSummary

Design game audio with grouped volume controls, music that responds to gameplay, and varied sound effects. Plan how music lowers during dialogue and how events follow the beat, using principles that can be adapted to different game engines.

  • Plan grouped volume controls for music, effects, and dialogue
  • Lower background music while dialogue plays
  • Change music layers or segments with gameplay intensity
gamedev-skills/awesome-gamedev-agent-skills3.7KUpdated Oct 23, 2026

bevy-ecs

FreeSummary

Build and debug Rust games in Bevy using ECS, a way to separate game data from behavior. Organize apps and plugins, query entities, control execution order, and fix conflicting data access or frame-dependent movement.

  • Organizing a Bevy app with plugins
  • Defining components and shared resources
  • Fixing conflicting queries and execution order
gamedev-skills/awesome-gamedev-agent-skills3.7KUpdated Oct 23, 2026

camera-systems

FreeSummary

Build and tune game cameras for smooth 2D following and 3D viewing. Covers motion smoothing, look-ahead, level boundaries, wall avoidance, and framing multiple targets, with techniques that apply across engines.

  • Smooth player-follow cameras in 2D games
  • Keep the camera view within level boundaries
  • Prevent third-person cameras from clipping through walls
gamedev-skills/awesome-gamedev-agent-skills3.7KUpdated Oct 23, 2026

card-game

FreeSummary

Design the core rules of a card game, including decks, hands, discards, drawing, shuffling, turns, and resource costs. Represent card effects as data and define their resolution order so card movement and gameplay outcomes follow explicit rules.

  • Building a deckbuilder or trading card game
  • Implementing draws and discard reshuffling
  • Defining turn phases and card costs
gamedev-skills/awesome-gamedev-agent-skills3.7KUpdated Oct 23, 2026

Plan and prepare consistent game artwork, from sprites and backgrounds to UI icons and 3D briefs. Organize asset requirements, generate or source related visuals, standardize files, and check their appearance and technical fit inside the game.

  • Create sprites and backgrounds with a consistent visual style
  • Check asset dimensions, transparency, and tile seams
  • Track asset sources and licenses before release
gamedev-skills/awesome-gamedev-agent-skills3.7KUpdated Oct 23, 2026

See all skills by gamedev-skills

Report a problem with this skill