How to make a first person animation work in game

Essentially, I want to have a beginning intro cutscene where you are seen waking up in first person and the problem is, I want the camera to be animated as well, I know how to make the camera follow your head in moon animator, but how do I translate this to the actual game?

1 Like

Also I would like to add, I have the animation finished already, and I attempted to force it to work with a script that uses a part parented to the head as the camera and unhides the torso arms and legs, but I don’t want to be able to control the camera and wiggle my character around, as It causes him to be flung and breaks immersion.

2 Likes

Can you please show me the animation?

1 Like

This isn’t the full animation but here you go.
https://gyazo.com/6a0a704298cf7a245c0086fb3ef723a4

The playback is previewed in moon animator, but in game the camera is stuck in a fixed position.

1 Like

First set the camera’s CameraType to Scriptable, then use :BindToRenderStep to set the camera’s CFrame to the head’s CFrame.

is the person doing a dance?
or is it an animation for something?

In the script used to play the animation, I added the scriptable camera type part, but nothing changed, also I have no idea how BindToRenderStep works, could you explain? here is the code:

--Variables--
local set = script.Settings
local sp = set.Speed
local enabled = set.Enabled
local hum = script.Parent:WaitForChild("Humanoid")
local camera =  game.Workspace.Camera
if hum then
	print("Success")
else
	print("No Humanoid")
end
local humanim = hum:LoadAnimation(script:FindFirstChildOfClass("Animation"))

--Playing Animation--
if enabled.Value == true then
	humanim:Play()
	humanim.Looped = false
	humanim:AdjustSpeed(sp.Value)
	camera.CameraType = Enum.CameraType.Scriptable
	hum.WalkSpeed = 0
	humanim.Stopped:wait()
	print("Resetting Camera...")
	camera.CameraType = Enum.CameraType.Custom
	hum.WalkSpeed = 12
end 

Its an animation of the character waking up.

check if there is any typos. if there isn’t, it might be another problem

I’m not getting any errors, so I don’t think its a typo.

Check the output to see if there are any errors.

I don’t think you’re binding anything to RenderStep:

local runService = game:GetService('RunService')
local function assignCameraToHead()
    camera.CFrame = head.CFrame
end
runService:BindToRenderStep('WeldToHead', Enum.RenderPriority.Last.Value, assignCameraToEnd)
-- then when the animation ends,
animation.Stopped:Wait() -- also use :Wait as :wait is deprecated
runService:UnbindFromRenderStep('WeldToHead')

Also check this out, it has a better explanation of how it works:

https://developer.roblox.com/en-us/api-reference/function/RunService/BindToRenderStep

I’m not an animator so maybe you could chat with another animator?

How would speaking to another animator help? I’m really just looking to have the camera follow the animation like it does in moon animator, but I’m not sure how to use BindToRenderStep, and I can’t find any tutorials that show how to implement camera controls from moon animator into my game.

Thank you for your help, I will try this.

1 Like

Alright I found a script that used the mentioned bindtorenderstep and it works nicely, but I can still move my camera and fling myself even after setting the camera type to scriptable, also this creates the same problem as the previous script that used a part parented to the head of the character as a camera, the camera doesnt follow the animation so it just looks in the same direction as the animation is playing.

Could you send the script you’re using?

here you go:

local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:wait()
local hum = char:WaitForChild("Humanoid")
local rootpart,head = char:WaitForChild("HumanoidRootPart"),char:WaitForChild("Head")
game:GetService("RunService"):BindToRenderStep("CameraOffset",Enum.RenderPriority.Camera.Value-1,function()
	hum.CameraOffset = (rootpart.CFrame+Vector3.new(0,1.5,0)):pointToObjectSpace(head.CFrame.p)
end)

That’s because you’re changing the CameraOffset property, you should be able to just assign the camera’s CFrame to the head’s CFrame:

workspace.CurrentCamera.CFrame = head.CFrame

Alright, I added that line after the cameraoffset line, and it appears to work, only problem is my character keeps spinning until the animation ends, this may have something to do with the fact that I can still control my camera even after setting the cameratype to scriptable, are you able to change the cameratype in a serverscript?