Lerping the Head of a Rig towards a certain point

Hello there!

I am currently trying to make my enemies feel more alive by making them look around the place, as of now all I want to do to make sure I understand the concept is just rotate the head by 90 degrees, sounds simple enough. It wasnt at all :skull:


Little disclaimer Ive never used :Lerp() before, it seems pretty straight forward, but if somehow Im doing something wrong please tell me.


Anyhow as I said I simply just want to rotate the head by 90 degrees, and by rotate the head I actually mean the Neck Motor6d of which can be found inside of the Torso (This is using an R6 rig btw).

Anyhow I cant seem to figure out how to do it at all, I’ve tried this, and Im not sure if Im just dumb, but the head doesnt rotate at all.
There are no errors, the Motor6d and other values all exist, so whats happening?

						local TestPoint = CFrame.Angles(0,math.rad(90),0)
						local ViewPoint:Motor6D = Enemy.Model:FindFirstChild('Neck', true)
						
						Enemy.Looking = true
						ViewPoint.C1:Lerp(TestPoint, 3)
						
						task.spawn(function()
							task.wait(3)
							Enemy.Looking = false
						end)

Thanks in advance!

1 Like

it needs to be

Neck.C1 = Neck.C1:Lerp()

Instead of

Neck.C1:Lerp()

since Lerp is a math function which returns result

also on a side note, i believe the roblox Neck Joint is quite weird :sob: so, you have to offset the Pitch/Roll, or else it’ll look weird… try it yourself

1 Like

:Lerp() takes a value between 0 and 1

A:Lerp(B,0.5)
--0 Would be the same as A
--1 Would be the same as B
--0.5 would be in-between the two of them

Also Lerp doesn’t smoothly move anything if you want it to animate something you can do something like

For i=0.1, 1, .1 do

A = A:Lerp(B, i)
task.wair(.1)

end

You can decrease the value of i and the third value to make it “smother” and increase/decrease the time to make it smoother/ snappier