LookVector is bit wierd

Hello! :smiley: Im a scripter, and making a pet following system currently, but the lookvector for the pet orientation is going bit weird.

I already dried finding some similar things on the devforum, but didnt found smth.

Im using CFrame, and pivotTo for the system

Heres some code thats going weird:

local LookPosition = Vector3.new(CharPosition.X,YRaycast,CharPosition.Z)
					
if PlayerMoving == true then
	LookPosition = Character.PrimaryPart.CFrame.LookVector -- ignore the y for now
end
					
local NewCFrame = CFrame.new(Position,LookPosition)
					
CreatePetModel:PivotTo(NewCFrame)

heres the result:

Since the pet is moving in world space, it must be looking in the direction relative to the world.

local NewCFrame = CFrame.new(Position, Position + LookPosition)

Instead of doing that you can just use cframe.angles with the humanoid root part like this:

local hrpcframe = -- whatever it equals

Pet.CFrame = CFrame.new(Pet.Position) * hrpcframe.Rotation

I think this should work but you might have to make adjustments. If .Rotation doesnโ€™t work use

CFrame.Angles(math.rad(-- angle here), -- repeat, -- repeat)

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