I have a flying pet that follows the player and it has align orientation to match the player’s HumanoidRootPart orientation but I want it to also tilt left and right rapidly to make it look more alive. What is the most smooth way to make this work?
If you are using an AlignOrientation
, you could probably just set the CFrame of the attachment for the player’s character with a slight angle offset continuously from left to right. You could also tween it, but if the AlignOrientation is not rigid then the physics should be smoothed anyways.
Example pseudocode:
local tiltingAngle = 10 --10 degree tilting back and forth
local angle = math.rad(tiltingAngle)
while true do --could make this an actual condition (like only when walking or something)
--Attachment.CFrame is an offset relative to the Attachment.Parent
--attachment0 would be the attachment of the AlignOrientation that is for the player
attachment0.CFrame = CFrame.Angles(0, 0, angle) --switch 'angle' into X instead of Z if the axis ends up being wrong
task.wait(1) --could use something more elegant than a simple wait
attachment0.CFrame = CFrame.Angles(0, 0, -angle)
task.wait(1)
end
You may need to adjust the properties of the AlignOrientation
to get the desired smoothness and responsiveness.