How to check when the player is flying backward

Hey, I’m currently working on a flying system

local function ReturnMoveDir()
	if Humanoid.MoveDirection == Vector3.new(0, 0, 0) then
		return Humanoid.MoveDirection
	end
	local CameraCFrame = (Camera.CFrame * CFrame.new((CFrame.new(Camera.CFrame.p, Camera.CFrame.p + Vector3.new(Camera.CFrame.lookVector.x, 0, Camera.CFrame.lookVector.z)):VectorToObjectSpace(Humanoid.MoveDirection)))).p - Camera.CFrame.p;
	if CameraCFrame == Vector3.new() then
		return CameraCFrame
	end
	return CameraCFrame.unit
end
TweenService:Create(BodyVelocity, TweenInfo.new(0.3), {Velocity = ReturnMoveDir()}):Play()

Basically, I want to check when the player is going backward so I can play a different flying animation. I tried checking the Humanoid.MoveDirection and the CameraCFrame thing that’s getting returned but they’re both vector3s so the direction won’t be relative to the player. How do I check if the player is indeed flying backward?

1 Like

i figured it out

local DirFromCam = Humanoid.MoveDirection:Dot(Camera.CFrame.LookVector)
	if DirFromCam < -0.75 then	
		print("backwards")
	end
1 Like

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