Animation offset

So, this animation is offsetting about 10 studs upon playing it in-game. Anyone know why?

Imagine this from 1st-person. That is what it should look like.


But looks like this:

Script Used

If nobody tries to solve this by the end of tomorrow, I’ll release the game without the ending cutscene and then wait for help later, as I’m trying to get the game done before school starts.

local typewriter = require(game:GetService("ReplicatedStorage").Functions.MiscFunctionStorage)

--Dialogue

local dialogue1 = "I got the key. Here."
local dialogue2 = "Alright, good. Now, let's just... Why isn't it working?"
local dialogue3 = "Wallace... Which lock did you grab?"
local dialogue4 = "The one from Air Control marked 'Do Not Use'... Oh."
local dialogue5 = "OH FOR GOODNESS SAKES!!!?"

--Module

local module = {}

function module:monitor(loadedAnimation, plr, deciderString)

	--Services

	local RunService = game:GetService("RunService")
	local TweenService = game:GetService("TweenService")

	--Guis

	local cutsceneGui = plr.PlayerGui.CutsceneGui
	local blackScreen = plr.PlayerGui.BlackScreen

	--Other Animations

	script.Parent.Humanoids.Wanda.Humanoid:FindFirstChildOfClass("Animator"):LoadAnimation(script.Wanda):Play()
	script.Parent.Humanoids.Wally.Humanoid:FindFirstChildOfClass("Animator"):LoadAnimation(script.Wally):Play()
	
	--Misc

	local blackScreenTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
	local skipCutscene = false
	local stop = false

	--Camera

	local camera = workspace.Camera
	local cameraPos = script.Parent.Humanoids.Camera.CameraPos

	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = cameraPos.CFrame

	coroutine.resume(coroutine.create(function()
		repeat
			RunService.Stepped:Wait()
			camera.CFrame = cameraPos.CFrame
		until stop
	end))

	--Add Marker

	local function addMarker(markerName, callback)
		loadedAnimation:GetMarkerReachedSignal(markerName):Connect(callback)
	end

	--Dialogue Start

	addMarker("Dialogue1Start", function()
		cutsceneGui.Enabled = true
		cutsceneGui.Speaker.Text = "Buddy"
		cutsceneGui.Speaker.TextColor3 = Color3.fromRGB(255, 255, 255)
		cutsceneGui.Dialogue.TextColor3 = Color3.fromRGB(255, 255, 255)
		typewriter.Typewriter(dialogue1, cutsceneGui.Dialogue)
	end)

	addMarker("Dialogue2Start", function()
		cutsceneGui.Speaker.Text = "???"
		cutsceneGui.Speaker.TextColor3 = Color3.fromRGB(170, 0, 255)
		cutsceneGui.Dialogue.TextColor3 = Color3.fromRGB(170, 0, 255)
		typewriter.Typewriter(dialogue2, cutsceneGui.Dialogue)
	end)

	addMarker("Dialogue3Start", function()
		cutsceneGui.Speaker.Text = "???"
		cutsceneGui.Speaker.TextColor3 = Color3.fromRGB(170, 0, 255)
		cutsceneGui.Dialogue.TextColor3 = Color3.fromRGB(170, 0, 255)
		typewriter.Typewriter(dialogue3, cutsceneGui.Dialogue)
	end)

	addMarker("Dialogue4Start", function()
		cutsceneGui.Speaker.Text = "Wallace"
		cutsceneGui.Speaker.TextColor3 = Color3.fromRGB(85, 170, 255)
		cutsceneGui.Dialogue.TextColor3 = Color3.fromRGB(85, 170, 255)
		typewriter.Typewriter(dialogue4, cutsceneGui.Dialogue)
	end)

	addMarker("Dialogue5Start", function()
		cutsceneGui.Speaker.Text = "???"
		cutsceneGui.Speaker.TextColor3 = Color3.fromRGB(170, 0, 255)
		cutsceneGui.Dialogue.TextColor3 = Color3.fromRGB(170, 0, 255)
		typewriter.Typewriter(dialogue5, cutsceneGui.Dialogue)
	end)

	--Dialogue End

	addMarker("Dialogue4End", function() cutsceneGui.Enabled = false end)
	
	addMarker("Dialogue5End", function() cutsceneGui.Enabled = false end)

	--Skip

	plr.PlayerGui.SkipCutscene.Enabled = true

	plr.PlayerGui.SkipCutscene.Button.Activated:Connect(function() skipCutscene = true end)

	--Ending Logic

	loadedAnimation:Play()

	local endTime = os.time() + 32

	repeat RunService.Stepped:Wait() until os.time() == endTime or skipCutscene
	
	stop = true

	--Black Screen

	blackScreen.Enabled = true

	TweenService:Create(blackScreen.BlackScreen, blackScreenTweenInfo, {BackgroundTransparency = 0}):Play()

	wait(1)

	if not skipCutscene then
		script.Parent.Parent.Scene2.Camera:monitor()
	else
		plr.PlayerScripts.RemoteEvents.MainMenu.MenuEvent:Fire()
	end

	wait(0.5)

	TweenService:Create(blackScreen.BlackScreen, blackScreenTweenInfo, {BackgroundTransparency = 1}):Play()

	wait(1)

	blackScreen.Enabled = false

end

return module
1 Like

If you want to anchor the player, you should anchor it via Character.HumanoidRootPart.

1 Like

So, I don’t know if that solved the anchoring problem. It might have, however, I’m still having the problem with the character being too far forwards, which is strange, considering that I specifically created the animation to fit with the map.

That sounds like an issue on the animation side of things, however it’s hard to say with a lack of context and details.

Imagine this from a 1st-Person perspective. That is what it should look like.


This is what it does look like.

I’m not all that familiar with scripting animations, so I can’t really say for sure. If it were me, I would’ve just scripted the player or character to move to that location so that it would use its walking animation, then play the animation for looking around. Though for more precise animation, you’ll probably want to animate the position as well (which I’m not familiar with).

I know I could do that, but I’d rather not, so I’m going to use that as a last resort.

Are you trying to have them watch the player from a third person type of view? I don’t really understand what you mean.

No, it’s supposed to be in first person. The should look like video is showing what the animation does, and so you kind of have to imagine the should look like video from 1st person. What’s happening is that the character in the looks like video is moving way too far forwards.

Ohh okay. Why don’t you try to change how far the player moves in the animation. If that does not work, I’d change where the player starts moving at, to make it how you want it to look. Because it seems to me that the player is already starting a bit more forward than it should.

I’m not sure why the player would start that far forwards, though. What you see in the first video is exactly what’s supposed to happen in the second, the starting position doesn’t change, and while I get that I could reduce the movement amount, I’d rather find why this is happening than find a roundabout solution to it.

Are you sure the camera’s cframe is being set to the head of the character?

Yea @3rdhoan123 does have a pretty good point. The camera offsetting could be messed up. I would try setting the camera’s subject to the head in a script when the character loads in. Or try locking first person via properties in StarterPlayer

Yes, there is a camera part that is positioned directly in front of the head,


and the camera’s position is constantly updated to its CFrame, using this script:

	coroutine.resume(coroutine.create(function()
		repeat
			RunService.Stepped:Wait()
			camera.CFrame = cameraPos.CFrame
		until stop
	end))

And no, after testing, the fact that I used coroutine.wrap() was not the problem.

When you play the game (and attach the camera to the camera part)

Try checking and seeing if the camera part still stays in the same location, if it seems to offset, you might accidently be messing around with the offset of your camerapos. You can try testing this by creating a part to symbolize the cframe of the players camera (where its supposed to be).

Check your animation and ensure you aren’t accidently moving that part forward either.

If it still doesn’t work, and you have no plans to actually really animate the “Camerapos”
You can instead attach the camera to the head (the head should still stay attached to the character?) and if it gets in the way, just set transparency to 1 temporarily.

Another thing to take into account, re-check your script, it seems you might be doing things unintended for the camera. Ensure your camera is set to scriptable so that no default part of the camera scripts run.

1 Like

None of this seemed to help at all, changing the camera subject for some reason made the animation not play and the mouse was stuck in the center of the screen, the camera position isn’t being offset at all, it is set to scriptable, and I’m not moving the camera forwards in the animation.

Have you tried checking the Server while you are playtesting? This is so that you can see your character in 3rd person. By doing this we would know if it is either a camera problem (if player is standing on where it should be) or a position problem (if player is standing at the door).

The cutscene plays on the client.

Yes I know, what I’m saying is to check the playtest on Server mode to see the player while the cutscene is playing on the Client side.

Dialogue can be useful if you are trying to make a realistic npc