要求的譯文尚未完成,目前顯示原始英文。
SKILL.md
唯讀
名稱
roblox-camera
描述
Use when scripting, fixing or reviewing Roblox cameras: occlusion, screen raycasts, shift lock, zoom, first person, shake, cutscenes, spectate.
Roblox Camera
When to Load
Changing the default camera's behaviour or replacing it: occlusion, screen-to-world rays, zoom and mouse-lock settings, first person, shake and recoil, cutscenes, spectate. Input binds: roblox-input; screen insets and safe areas: roblox-ui §1.
"Field case" = seen in one of the owner's projects; verify on your content.
Traps and review checklist (symptom -> cause -> fix)
- Camera clips through walls after a map rebuild (meshes + invisible collision boxes) -> the default camera only pulls in for parts that are
CanCollide = trueand mostly opaque. Visual meshes withCanCollide = falseare ignored, and so are invisible proxies:Camera:GetLargestCutoffDistance(which PopperCam uses) skipsCanCollide = false,Transparency > 0.95and water; the PlayerModule's Popper source was seen skipping total transparency >= 0.25, countingLocalTransparencyModifier(check the current source). Make collidable, visible geometry stand where the walls are (§1). - "Fixed" occlusion still clips in Play -> property checks aren't proof. Verify against the real geometry: cast the camera's rays against the old and new map at the same sample points and compare hit distances, then back the camera into walls at known spots (§1).
- Hiding spot, locker or vehicle shell shoves the camera in -> ghost it locally with
LocalTransparencyModifierpast the threshold above instead of turning off collision.DevCameraOcclusionMode(Zoomdefault,Invisicam) is set onStarterPlayerand can't be changed per player. - Aim ray off by the top bar -> mixed coordinate spaces.
UserInputService:GetMouseLocation()ignores the inset ->ViewportPointToRay;InputObject.Position(mouse/touch) andScreenPointToRay/WorldToScreenPointinclude the inset. Both rays are unit length: scaleDirectionbeforeRaycast. - Shift lock, camera mode or movement mode won't change from a LocalScript ->
DevEnableMouseLock,DevComputerCameraMode,DevComputerMovementModeare server-set only (defaults fromStarterPlayer); the player can still turn the mouse-lock switch off in settings, so never make shift lock the only way to aim.CameraMaxZoomDistancebelowCameraMinZoomDistanceis raised to the minimum; equal values lock zoom. - Orthographic view works in Studio, not live ->
Camera.ProjectionType = Orthographic(OrthographicSize,OrthographicMode) is a Studio beta; published games can't use it yet <!-- temporal: 2026-11 -->. Screen rays are parallel there; recheck world-to-screen maths. - View drifts after recoil, head bob or rotational shake -> the default camera reads its own CFrame back as input: ±4° kicks re-based on it drifted 1.7°-17.8° pitch and 2.7°-17.7° yaw over a few runs; translation-only shake drifted 0° (field-measured). Remove the kick before the camera step and re-apply after (§2).
- Cutscene or test camera snaps back after setting
Scriptable-> the game's own camera controller keeps writingCFrame. Bind the override atRenderPriority.Last, disable the project's first-person/viewmodel controllers for the shot, confirm the CFrame held next frame (field case). - Fast subject (launch, vehicle, ragdoll) trails or shakes -> an exponential follow lags by about
speed / rate(~6 studs at 80 studs/s, rate 14). Lead the follow point byAssemblyLinearVelocity * dt, then lerp (average error ~0.3 studs, worst 0.95, field-measured); follow an anchored proxy moved atCamera.Value - 1, not the tumbling Head. - Zoom lands short after a tweened pull-in -> hold the final
CameraMin/MaxZoomDistancethrough at least one native camera update before reopening free zoom (~0.2 studs lost per cycle otherwise); compare stored zoom with ~0.1-stud tolerance (field-measured). - Spare cameras vanish / ViewportFrame rays wrong -> setting
Workspace.CurrentCameradestroys otherCameras directly underWorkspace(keep them in a Folder or Model). OnlyCurrentCameraupdatesViewportSize;ScreenPointToRayworks only for it. UseViewportCameraforViewportFrame.CurrentCamera: it replicates and works in Team Create. - Collision-safe offset still clips at corners ->
Spherecast/Blockcastdon't detect parts the shape starts inside. Handle start overlaps separately, let clearance override the preferred minimum distance, and test corners, shelves and low ceilings. - Death cam or spectate leaves the wrong subject or locked controls after respawn -> restore to the current character and controller, not a snapshot taken before a respawn or newer camera mode; release on timeout, subject removal and round change.
CameraSubject = nilreverts to the previous subject.
What changed
| Change | Use now |
|---|---|
CFrame.new(pos, lookAt) replaced |
CFrame.lookAt(at, target, up?); near straight up/down pass your own up or use CFrame.fromMatrix (the default up flips to the X axis) |
Player:GetCameraState() (Server Authority) <!-- temporal: 2026-11 --> |
server reads any player's CFrame/FieldOfView/ViewportSize for aim validation; CFrame comes via the input stream, FOV/size via property replication, so they can disagree; still player data (roblox-security) |
| Free camera | Left Shift + P for owners/editors in playtests and live; its menu needs Workspace.PlayerScriptsUseInputActionSystem. Debug and footage only, not a spectator mode |
1. Occlusion fix and verification (m-0083 shape)
- Verify in Play on both maps: from the character's head,
Camera:GetLargestCutoffDistance({character})at sampled camera positions, orworkspace:Raycast(focus, cameraPos - focus, params)(exclude the character) along walls, roofs and doorways. Every sample that hit on the old map must hit at about the same distance on the new one. Then walk the camera into a few walls on PC, phone and gamepad.
2. Rotational kick without drift
-- Illustrative: kick never leaks into the default camera's aim.
local CAM = Enum.RenderPriority.Camera.Value
local kick, applied = CFrame.identity, nil -- recoil code writes `kick`
RunService:BindToRenderStep("KickRemove", CAM - 2, function()
if applied then camera.CFrame *= applied:Inverse(); applied = nil end
end)
RunService:BindToRenderStep("KickApply", CAM + 3, function()
if kick ~= CFrame.identity then camera.CFrame *= kick; applied = kick end
end)
Several kickers nest last-on-first-off (B applied at +4 comes off at -3, before A at -2). Verify by recording pitch and yaw before a burst and after it settles, over several bursts: they must return exactly.






