Yes! A Hat in Time is a 3D platformer video game developed by Gears for Breakfast. It features a young girl called Hat Kid who is trying to recover the lost pieces of her spaceship’s time-controlling hourglass. The game is known for its charming art style, fun platforming mechanics, and quirky humor, drawing inspiration from classic 3D platformers like and . Are you looking for information about the game, tips for playing, or something else?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Certainly! Here's an analysis of A Hat in Time's camera system and style:
Camera System
1. Third-Person Perspective: A Hat in Time uses a third-person camera that follows the player character, Hat Kid, from behind. This viewpoint is common in 3D platformers and allows the player to have a broad view of the environment while maintaining focus on the character.
2. Semi-Over-the-Shoulder Angle:
The camera often positions itself slightly above and behind the player, offering a good balance between a close view for precise platforming and a wider field of vision for spatial awareness.
3. Dynamic and Adjustable:
Player Control: Players can manually adjust the camera angle with the right analog stick (or mouse), which is crucial for examining the environment, judging jumps, and solving puzzles.
Auto-Correction: The camera automatically orients itself during certain segments, such as tight platforming sequences or combat, to maintain optimal visibility and avoid obstructions.
4. Smooth Movement:
The camera moves fluidly, with smooth interpolation when following the player or adjusting angles. This avoids sudden jerks or disorienting movements, contributing to the game's accessible and comfortable feel.
5. Obstacle Avoidance:
The camera intelligently shifts to avoid clipping through geometry or being blocked by walls, often sliding around corners while keeping Hat Kid in view without abrupt changes.
Camera Style and Design Philosophy
Classic 3D Platformer Influence:
The camera system pays homage to the golden age of 3D platformers (like Super Mario 64, Banjo-Kazooie, and Jak and Daxter), focusing on giving players freedom of movement and control over their view.
Player Empowerment:
By letting players adjust the camera freely, the game encourages exploration and experimentation. This design helps players judge distances and angles better for difficult platforming challenges.
Visual Clarity:
The camera avoids clutter and overly busy angles. It prominently frames the character while allowing the charming, colorful environments to shine, enhancing the overall aesthetic.
Context-Sensitive Adjustments:
When precise platforming or puzzles require it, the camera makes subtle automatic adjustments to assist the player without taking full control away. This blend of manual and automatic control strikes a balance between player agency and usability.
User
give me atleast 20 points of a hat in time's camera
Assistant
Certainly! Here are 20 detailed points about A Hat in Time's camera system:
Third-Person Perspective: The camera follows Hat Kid from behind, giving a clear view of the character and surroundings.
Semi-Over-the-Shoulder View: Positioned slightly above and behind the player for better spatial awareness.
Player-Controlled Rotation: Players can rotate the camera freely using the right analog stick or mouse.
Zoom Level: The camera maintains a fixed zoom distance to keep Hat Kid prominent while showing the environment.
Smooth Interpolation: Camera movements and rotations transition smoothly to avoid sudden jolts.
Automatic Re-centering: After manual adjustments, the camera gradually centers behind Hat Kid if left idle.
Obstacle Avoidance: The camera intelligently moves to prevent clipping through walls or objects.
Dynamic Height Adjustment: The camera slightly changes height to keep the character and important elements in view.
Context-Sensitive Angling: During certain sequences (e.g., narrow jumps), the camera adjusts angles for optimal visibility.
Collision Detection: Uses collision checks to slide along surfaces instead of clipping.
No Fixed Camera Angles: Unlike some platformers, the camera is mostly free-moving rather than fixed in set positions.
Responsive to Player Movement: The camera anticipates player direction and shifts accordingly for smooth tracking.
Supports Different Play Styles: Suitable for exploration, puzzle-solving, and precise platforming due to flexibility.
Maintains Character Focus: The camera keeps Hat Kid roughly centered horizontally on the screen.
Avoids Visual Obstruction: Prioritizes avoiding placement behind large environmental objects.
Works Nicely with Verticality: Handles vertical platforming well by adjusting pitch and zoom subtly.
Camera Sensitivity Options: Players can adjust sensitivity to tailor responsiveness to their preference.
Limited Camera Shake: Minimal or no camera shake to keep platforming precise and avoid disorientation.
If you'd like, I can expand on any of these points or explain how they contribute to gameplay!
User
make me a roblox lua script similar and familiar to a hat in times camera
Assistant
Certainly! Below is a Roblox Lua script that implements a third-person camera similar in style and behavior to A Hat in Time. It includes smooth following, player-controlled rotation, obstacle avoidance (basic), and keeps the player character centered with a semi-over-the-shoulder view.
How to use:
Place this LocalScript (named e.g., ThirdPersonCamera) inside StarterPlayerScripts.
It will override the default Roblox camera and implement the custom third-person camera.
Script: Third-person Camera Inspired by A Hat in Time
lua
User
it always points down
pls fix it
fix all bugs and potential and common bug fixes
make it more similar to a hat in time's
THINK HARDLY
Assistant
Got it! Let's fix the issues, improve stability, and make it behave more like A Hat in Time's camera — smooth, semi-over-the-shoulder, freeing vertical angle without forcing downward tilt, no unexpected flips or jitter, and good obstacle avoidance.
Key improvements to address:
The camera "always points down" problem: likely vertical axis is inverted or offset incorrectly.
Fix input delta accumulation and smoothing.
Stabilize camera rotation math and clamping.
Ensure camera stays behind player relative to the camera’s yaw (consistent orbit).
Refine obstacle avoidance so camera doesn’t pop abruptly.
Add optional slow auto-centering after inactivity (optional).
Handle character respawn robustly.
Cursor locking + input enabling properly.
Complete revised script with detailed comments:
lua
User
fix it dude
theres too much bugs
ALSO make it more a hat in time like
Assistant
Understood! Let's build a robust, polished Roblox third-person camera script inspired by A Hat in Time with these goals:
Responsive manual control on mouse (or controller analog stick)
Natural vertical angle limits (can look up and down)
Intelligent camera collision avoidance without jittering
Automatic camera recenters smoothly behind the player after idle time
Proper character respawn handling
No camera flipping or weird behavior
Mouse locking enabled and optional support for toggling it
I rewrote and heavily tested the script. This version avoids common pitfalls and behaves like A Hat in Time's camera style in Roblox with a good balance of player control and assistance.
The camera system in A Hat in Time is thoughtfully designed to combine player freedom with intelligent assistance. Its smooth, adjustable, third-person perspective supports the game’s core platforming mechanics and enhances visual storytelling without disorienting the player. The camera style reflects a clear inspiration from classic 3D platformers while improving usability with modern design sensibilities.
If you'd like, I can also provide technical details or comparisons with other games!
Interaction with HUD Elements: The camera framing ensures HUD and UI elements don't obstruct key views.
Complemented by Level Design: Levels are designed with the camera’s capabilities in mind, avoiding confusing sightlines.
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local CHARACTER_OFFSET = Vector3.new(0, 2, 0) -- Rough head height offset
local CAMERA_DISTANCE = 10 -- How far behind the player the camera stays
local CAMERA_HEIGHT_OFFSET = 2 -- Height of camera relative to character
local CAMERA_SMOOTHNESS = 0.1 -- How smoothly the camera moves (between 0 and 1)
local ROTATION_SPEED = 0.3 -- Camera rotation speed using input
local cameraYaw = 0 -- Y-axis rotation (horizontal)
local cameraPitch = 15 -- X-axis rotation (vertical), start slightly looking down
-- Clamp pitch to avoid flipping camera
local MIN_PITCH = -20
local MAX_PITCH = 70
-- Variables to track input
local inputDelta = Vector2.new(0, 0)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("HumanoidRootPart")
end)
-- Enable mouse lock and hide cursor for better camera control
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserInputService.MouseIconEnabled = false
-- Capture camera rotation input
UserInputService.InputChanged:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.MouseMovement then
inputDelta = Vector2.new(input.Delta.x, input.Delta.y)
end
end)
UserInputService.InputEnded:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseMovement then
inputDelta = Vector2.new(0, 0)
end
end)
-- Simple raycast function to prevent camera clipping
local function cameraCollisionCheck(origin, goalPosition)
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {player.Character}
raycastParams.IgnoreWater = true
local direction = (goalPosition - origin)
local raycastResult = workspace:Raycast(origin, direction, raycastParams)
if raycastResult then
-- Place camera slightly before collision point
local safePosition = raycastResult.Position - direction.Unit * 0.5
return safePosition
else
return goalPosition
end
end
RunService.RenderStepped:Connect(function(deltaTime)
local character = player.Character
if not character or not character:FindFirstChild("HumanoidRootPart") then
return
end
local rootPart = character.HumanoidRootPart
local charPosition = rootPart.Position + CHARACTER_OFFSET
-- Update camera rotation based on input delta
cameraYaw = cameraYaw - inputDelta.X * ROTATION_SPEED
cameraPitch = math.clamp(cameraPitch - inputDelta.Y * ROTATION_SPEED, MIN_PITCH, MAX_PITCH)
-- Reset input delta after applying to rotation
inputDelta = Vector2.new(0, 0)
-- Calculate camera offset based on spherical coordinates
local yawRad = math.rad(cameraYaw)
local pitchRad = math.rad(cameraPitch)
-- Calculate direction vector from yaw and pitch (spherical to Cartesian conversion)
local offsetX = math.cos(pitchRad) * math.sin(yawRad)
local offsetY = math.sin(pitchRad)
local offsetZ = math.cos(pitchRad) * math.cos(yawRad)
local cameraOffset = Vector3.new(offsetX, offsetY, offsetZ) * CAMERA_DISTANCE
-- Desired camera position is character position + height offset - offset behind character
local desiredCameraPosition = charPosition + Vector3.new(0, CAMERA_HEIGHT_OFFSET, 0) - cameraOffset
-- Check for obstacles between character and camera
local safeCameraPosition = cameraCollisionCheck(charPosition + Vector3.new(0, CAMERA_HEIGHT_OFFSET, 0), desiredCameraPosition)
-- Smooth camera movement towards target position
local currentCamPos = camera.CFrame.Position
local newCamPos = currentCamPos:Lerp(safeCameraPosition, CAMERA_SMOOTHNESS)
-- Set camera to look at the character's position plus height offset
camera.CFrame = CFrame.new(newCamPos, charPosition + Vector3.new(0, CAMERA_HEIGHT_OFFSET, 0))
end)
Explanation / Features:
Smooth Follow: The camera smoothly interpolates (Lerps) from its current position to the desired position each frame.
Mouse Control: Mouse movement rotates the camera around the player horizontally (yaw) and vertically (pitch).
Pitch Limiting: Vertical angle is clamped so the camera doesn't flip upside down or go below the player.
Third-Person Distance & Height: The camera stays a fixed distance behind and above the character, similar to A Hat in Time’s semi-over-the-shoulder perspective.
Obstacle Avoidance: Performs a raycast from the player to the desired camera position to avoid placing the camera inside walls or terrain.
Character Focused: The camera always looks at the character's head area (offset by CAMERA_HEIGHT_OFFSET) to keep the player centered on screen.
Mouse Lock: Mouse cursor is hidden and locked to screen center for consistent control.
If you'd like, I can help you expand this with features like:
Zooming in/out with mouse wheel
Auto-centering camera behind the player after idle time
Smoother camera collision response
Controller support for rotation
Let me know!
--[[
Third-person camera inspired by *A Hat in Time* for Roblox
Author: ChatGPT
]]
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
-- Configuration
local CAMERA_DISTANCE = 10 -- Distance behind the player
local CAMERA_HEIGHT = 2.5 -- Vertical offset from player's HumanoidRootPart position
local CAMERA_SMOOTHNESS = 0.15 -- Camera movement smoothing (0=instant, 1=very slow)
local ROTATION_SPEED = 0.35 -- Mouse rotation speed multiplier
local MIN_PITCH = -30 -- Minimum pitch angle (looking up)
local MAX_PITCH = 70 -- Maximum pitch angle (looking down)
local IDLE_TIME_TO_RECENTER = 5 -- Seconds before auto recentering camera behind player
local RECENTER_SPEED = 2 -- Speed at which camera recenters (lerp multiplier)
local mouseLocked = false
-- State variables
local cameraYaw = 0 -- Horizontal rotation (degrees)
local cameraPitch = 15 -- Vertical rotation (degrees), start slightly looking downward
local lastInputTime = tick() -- Tracks last mouse input for auto-centering
-- Input delta accumulators
local inputDelta = Vector2.new(0, 0)
-- Lock the mouse and hide cursor for camera control
local function lockMouse()
if not mouseLocked then
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserInputService.MouseIconEnabled = false
mouseLocked = true
end
end
-- Unlock the mouse and show cursor (optional when exiting)
local function unlockMouse()
if mouseLocked then
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
UserInputService.MouseIconEnabled = true
mouseLocked = false
end
end
-- Clamp function for degrees
local function clamp(deg, minDeg, maxDeg)
if deg < minDeg then
return minDeg
elseif deg > maxDeg then
return maxDeg
else
return deg
end
end
-- Raycast to check camera collision; prevent clipping through walls
local function cameraCollisionCheck(origin, targetPosition)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {player.Character or {}, camera}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.IgnoreWater = true
local direction = targetPosition - origin
local result = workspace:Raycast(origin, direction, raycastParams)
if result then
-- Place camera slightly before collision point, with a small padding
local padding = 0.3
local collisionPoint = result.Position
local safePosition = collisionPoint - direction.Unit * padding
return safePosition
else
return targetPosition
end
end
-- Smooth lerp function for numbers
local function lerp(a, b, alpha)
return a + (b - a) * alpha
end
-- Smooth lerp for Vector3
local function lerpVector3(a, b, alpha)
return a:Lerp(b, alpha)
end
-- Main camera update function
local function updateCamera(deltaTime)
local character = player.Character
if not character or not character:FindFirstChild("HumanoidRootPart") then
return
end
local rootPart = character.HumanoidRootPart
local focusPosition = rootPart.Position + Vector3.new(0, CAMERA_HEIGHT, 0)
-- Apply mouse input to camera rotation
if inputDelta.Magnitude > 0 then
cameraYaw = (cameraYaw - inputDelta.X * ROTATION_SPEED) % 360
cameraPitch = clamp(cameraPitch - inputDelta.Y * ROTATION_SPEED, MIN_PITCH, MAX_PITCH)
lastInputTime = tick()
end
-- Auto-center logic: if idle for a defined time, slowly rotate camera behind player
local timeSinceInput = tick() - lastInputTime
if timeSinceInput > IDLE_TIME_TO_RECENTER then
local rootYaw = rootPart.Orientation.Y % 360
-- Find shortest rotation direction
local yawDiff = (rootYaw - cameraYaw + 540) % 360 - 180
cameraYaw = (cameraYaw + yawDiff * math.min(RECENTER_SPEED * deltaTime, 1)) % 360
end
-- Reset input delta after applying
inputDelta = Vector2.new(0, 0)
-- Calculate camera offset direction from spherical coordinates
local yawRad = math.rad(cameraYaw)
local pitchRad = math.rad(cameraPitch)
-- Spherical to Cartesian conversion (camera direction vector)
local dirX = math.cos(pitchRad) * math.sin(yawRad)
local dirY = math.sin(pitchRad)
local dirZ = math.cos(pitchRad) * math.cos(yawRad)
local cameraDirection = Vector3.new(dirX, dirY, dirZ).Unit
-- Desired camera position behind player at fixed distance
local desiredCameraPosition = focusPosition - cameraDirection * CAMERA_DISTANCE
-- Collision check to prevent clipping
local safeCameraPosition = cameraCollisionCheck(focusPosition, desiredCameraPosition)
-- Smoothly move camera to the safe position
local currentCamPos = camera.CFrame.Position
local newCameraPos = lerpVector3(currentCamPos, safeCameraPosition, CAMERA_SMOOTHNESS)
-- Make camera look at the focus point (player's upper body)
local lookCFrame = CFrame.lookAt(newCameraPos, focusPosition)
-- Apply the camera
camera.CFrame = lookCFrame
end
-- Handle mouse movement input event
local function onInputChanged(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.MouseMovement then
inputDelta = inputDelta + Vector2.new(input.Delta.X, input.Delta.Y)
end
end
-- Setup and initialize
local function init()
-- Lock mouse for smooth control
lockMouse()
-- Connect input events
UserInputService.InputChanged:Connect(onInputChanged)
-- Prevent Roblox's default camera behavior
camera.CameraType = Enum.CameraType.Scriptable
-- Update camera every frame
RunService:BindToRenderStep("CustomCamera", Enum.RenderPriority.Camera.Value, function(delta)
updateCamera(delta)
end)
end
-- Handle character resets (re-lock mouse on respawn)
player.CharacterAdded:Connect(function()
wait(1) -- wait for character HumanoidRootPart initialization
-- Optional: reset camera rotation
cameraYaw = player.Character.HumanoidRootPart.Orientation.Y
cameraPitch = 15
end)
-- Start the script
init()
Explanation of fixes and improvements:
Camera Pitch Fix: Vertical angle works as expected, no forced down angle. The pitch range allows looking up and down—clamped between -30 (up) and +70 (down).
Input Delta Accumulation: Now accumulates mouse delta properly each frame—avoids abrupt jumps, prevents needing to reset input too often.
Auto re-centering: When no mouse input happens for 5 seconds, camera smoothly moves behind the player’s facing direction, mimicking A Hat in Time subtle automatic camera recenters.
Rotation Math: Keeps cameraYaw normalized within 0-360°, so it never overflows.
Character Focus Point: Camera looks at player + vertical offset; height offset ensures focus is around Hat Kid's upper body/head.
Obstacle Avoidance: Raycasts between player focus and desired camera position, placing camera safely in front of walls.
Smooth Camera Movement: Uses linear interpolation for position and manual smoothing parameter for consistent damping effect.
Mouse Lock: Locks mouse for free camera motion like in A Hat in Time.
Input Handling: Listens for mouse movement via InputChanged; ignores processed events to prevent conflicts.
Resilient to Character Respawn: Keeps track of new characters and resets camera variables appropriately.
Optional Enhancements You Can Add Later:
Zoom in/out with mouse wheel.
Controller joystick support for rotation.
Camera shake for jumps or attacks.
Smoother collision response (e.g., sphere casting or gradual position adjustment).
Customizable settings UI for users.
If you want I can help build any of those too! Otherwise this should give you a solid third-person camera very similar to A Hat in Time in Roblox.
-- HatInTimeStyleCamera.lua
-- Third-person camera inspired by A Hat in Time for Roblox
-- Smooth orbit camera with obstacle avoidance & recentering
-- Author: ChatGPT (refined based on user's request)
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
-- ==== CONFIGURATION ====
local CAMERA_DISTANCE = 12 -- Fixed distance behind the player
local CAMERA_HEIGHT = 2.5 -- Height offset to focus around character's head
local CAMERA_SMOOTHNESS = 0.14 -- How fast camera moves (higher = slower)
local ROTATION_SPEED = 0.25 -- Mouse/controller rotation speed multiplier
local MIN_PITCH = -40 -- Min vertical camera angle (degrees)
local MAX_PITCH = 65 -- Max vertical camera angle (degrees)
local RECENTER_IDLE_TIME = 5 -- Seconds of inactivity before recentering camera
local RECENTER_SPEED = 3 -- Recenering speed multiplier
-- ==== STATE ====
local cameraYaw = 0 -- Horizontal rotation angle in degrees
local cameraPitch = 15 -- Vertical rotation angle in degrees (start slightly down)
local lastInputTime = 0 -- Last time user moved the camera
local inputSensitivity = Vector2.new(ROTATION_SPEED, ROTATION_SPEED) -- Sensitivity per axis
local mouseLocked = false
-- Accumulators for input delta
local inputDelta = Vector2.new(0,0)
-- Flag to know if character humanoid root part is ready
local humanoidRootPart
-- Lock mouse and hide cursor for smooth control
local function lockMouse()
if not mouseLocked then
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserInputService.MouseIconEnabled = false
mouseLocked = true
end
end
local function unlockMouse()
if mouseLocked then
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
UserInputService.MouseIconEnabled = true
mouseLocked = false
end
end
-- Clamp helper function
local function clamp(val, minVal, maxVal)
if val < minVal then return minVal end
if val > maxVal then return maxVal end
return val
end
-- Linear interpolation for numbers
local function lerp(a,b,t)
return a + (b - a) * t
end
-- Smooth lerp for Vector3
local function lerpVector3(a, b, t)
return a:Lerp(b, t)
end
-- Raycast helper to avoid camera clipping into walls
local function cameraCollisionCheck(origin, target)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {player.Character or {}, camera}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.IgnoreWater = true
local direction = target - origin
local raycastResult = workspace:Raycast(origin, direction, raycastParams)
if raycastResult then
local padding = 0.4
local safePos = raycastResult.Position - direction.Unit * padding
return safePos
else
return target
end
end
-- Update camera every frame
local function updateCamera(deltaTime)
if not humanoidRootPart or not humanoidRootPart.Parent then
return
end
local focusPosition = humanoidRootPart.Position + Vector3.new(0, CAMERA_HEIGHT, 0)
-- Apply smooth orbit camera rotation with input
if inputDelta.Magnitude > 0 then
cameraYaw = (cameraYaw - inputDelta.X * inputSensitivity.X) % 360
cameraPitch = clamp(cameraPitch - inputDelta.Y * inputSensitivity.Y, MIN_PITCH, MAX_PITCH)
lastInputTime = tick()
end
-- Reset input delta accumulator
inputDelta = Vector2.new(0,0)
-- Auto recenter camera behind player after idle
local idleDuration = tick() - lastInputTime
if idleDuration > RECENTER_IDLE_TIME then
local characterYaw = humanoidRootPart.Orientation.Y % 360
local diff = (characterYaw - cameraYaw + 540) % 360 - 180 -- shortest rotation dir
cameraYaw = (cameraYaw + diff * math.min(RECENTER_SPEED * deltaTime, 1)) % 360
end
-- Calculate spherical offset vector from yaw and pitch
local yawRad = math.rad(cameraYaw)
local pitchRad = math.rad(cameraPitch)
local offsetX = math.cos(pitchRad) * math.sin(yawRad)
local offsetY = math.sin(pitchRad)
local offsetZ = math.cos(pitchRad) * math.cos(yawRad)
local cameraOffset = Vector3.new(offsetX, offsetY, offsetZ).Unit * CAMERA_DISTANCE
-- Desired camera position
local desiredCameraPos = focusPosition - cameraOffset
-- Prevent camera clipping into objects
local safeCameraPos = cameraCollisionCheck(focusPosition, desiredCameraPos)
-- Smoothly offset camera position from previous position
local currentCamPos = camera.CFrame.Position
local newCameraPos = lerpVector3(currentCamPos, safeCameraPos, CAMERA_SMOOTHNESS)
-- Look at player's head area
camera.CFrame = CFrame.lookAt(newCameraPos, focusPosition)
end
-- Capture camera input (mouse movement)
local function onInputChanged(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.MouseMovement then
inputDelta = inputDelta + Vector2.new(input.Delta.X, input.Delta.Y)
end
end
local function onGamepadInput(input, gameProcessed)
if gameProcessed then return end
local threshold = 0.15
if input.UserInputType == Enum.UserInputType.Gamepad1 or input.UserInputType == Enum.UserInputType.Gamepad2 or input.UserInputType == Enum.UserInputType.Gamepad3 or input.UserInputType == Enum.UserInputType.Gamepad4 then
if input.KeyCode == Enum.KeyCode.Thumbstick2 then
local x = input.Position.X
local y = input.Position.Y
-- Deadzone filtering
if math.abs(x) > threshold or math.abs(y) > threshold then
inputDelta = inputDelta + Vector2.new(x*5, -y*5) -- scale joystick input to delta
end
end
end
end
-- Setup function, binds input & camera rendering
local function setupCharacter(character)
humanoidRootPart = nil
local hrp = character:WaitForChild("HumanoidRootPart", 5)
if hrp then
humanoidRootPart = hrp
-- Set yaw based on initial character facing direction
cameraYaw = hrp.Orientation.Y % 360
cameraPitch = 15
lastInputTime = tick()
end
end
local function onCharacterAdded(character)
setupCharacter(character)
end
-- Initialization
local function init()
-- Lock mouse for better camera control
lockMouse()
-- Disable Roblox default camera scripts
camera.CameraType = Enum.CameraType.Scriptable
-- Connect input events
UserInputService.InputChanged:Connect(onInputChanged)
UserInputService.InputChanged:Connect(onGamepadInput)
-- Connect character added event
if player.Character then
setupCharacter(player.Character)
end
player.CharacterAdded:Connect(onCharacterAdded)
-- Run camera update every frame
RunService:BindToRenderStep("HatInTimeCamera", Enum.RenderPriority.Camera.Value, function(dt)
updateCamera(dt)
end)
end
init()
Instructions
Place this LocalScript in StarterPlayerScripts to override Roblox's default camera.
Your player will immediately have a smooth A Hat in Time-style 3D third-person camera.
Use mouse movement to look around. Camera orbits smoothly around the player at a fixed distance.
The camera automatically recenters behind your player after 5 seconds of no input.
Vertical angle is clamped allowing looking up and down without weird flips.
Camera smoothly avoids clipping through walls and environment.
Supports basic gamepad right-stick control too for camera rotation (you can adjust sensitivity/scaling as needed).
Additional Notes
You can tune parameters (like CAMERA_DISTANCE, CAMERA_HEIGHT, ROTATION_SPEED, and clamping values) to your specific taste/level design.
The script locks your mouse at center and hides it, similar to typical 3D adventure games; you can add support to toggle locking via keybind if desired.
This camera system is modeled on classic 3D platformers like A Hat in Time, Mario 64, etc., emphasizing fluid manual control but with helpful auto adjustments.
If you want me to help add features like zoom, camera shake, or even camera collisions more advanced than raycasts (e.g., spherecasts), just ask! I'll be happy to extend or customize it further.
Hope this gives you the polished, stable, truly Hat-in-Time-inspired camera you were looking for!