Animations mixing with script setting Motor6D

Got this simple script which rotates the camera towards the direction you’re looking (up and down only)

local RATE = 1/10
local t = 0
runservice.Heartbeat:Connect(function(dt)
	t += dt
	local lookvector = camera.CFrame.LookVector
	neck.C0 = CFrame.new(0, 0.8, 0) * CFrame.Angles(lookvector.Y, 0, 0)
	if t > RATE then
		-- don't loop to not spam remote events.
		t = 0
		--replication.ClientLook:FireServer(camera.CFrame.LookVector)
	end
end)

How would this blend with animations that also control the head?
Would they get overridden?

If they do, how do I make sure they blend?

As an example, there could be a reload animation which makes your head turn, or aiming down sights.

1 Like

could you please show me the full code so i can understand it better and maybe use it?
thank you.

use it?

This is the full code. The relevant bits anyway. The rest are obvious stuff like local player = game:GetService("Players").LocalPlayer

ah. i see
i will test it out soon enough

What? Can you answer my question?

After debugging it, I can safely say that no it doesn’t override the animations.
To actually override the animations, you need to delete the animate script from the player’s character immediately after it spawns.

1 Like

Also, It kinda looks strange with my head being backwards and facing the ground.
That’s just the side-effect of using C0 instead of transform.

Here’s my code:

local player = game:GetService("Players").LocalPlayer
local camera = workspace.CurrentCamera
local character = player.CharacterAdded:Wait()
local torso = character:FindFirstChild("Torso")

local RATE = 1/10
local t = 0

game:GetService("RunService").Heartbeat:Connect(function(dt)
	t += dt
	local lookvector = camera.CFrame.LookVector
	torso:FindFirstChild("Neck").C0 = CFrame.new(0, 0.8, 0) * CFrame.Angles(lookvector.Y, 0, 0)
	if t > RATE then
		-- don't loop to not spam remote events.
		t = 0
		--replication.ClientLook:FireServer(camera.CFrame.LookVector)
	end
end)

Cheers. I’m just making sure it DOESN’T override animations.

Is there a way to blend both though?

It already blends both together, like using a slash animation and then using cframe to basically make inverse kinematics out of an existing keyframe animation.

1 Like

Is the CFrame that the script sets kind of like the “base” position for animations to act from?

If you make it so it acts like that then yeah, otherwise it would just override a part of the animation.

1 Like

How would I make it “act like that”?

(Also how could I set different priorities then for this situation?)

Roblox uses the Transform property to change the offset of the motord6d while playing animations, so if you want blending you can lerp your cframe to the cframe of the Transform property to create a blending effect if that makes sense

local cframe = ... -- the cframe you want to apply to C0
local newCFrame = cframe:Lerp(motor6d.Transform, 0.5)
motor6d.C0 = newCFrame

edit: didn’t put too much thought into this so you might wanna play around with it a little bit

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.