Hello! At the moment, I’m working on a following system for flying familiars in my game, which will follow the player and move according to the player’s movement (but with drag and their own movements included). I thought of some methods, but I’m not sure which would be more performant and smooth.
-Exclusively animation: Will be very smooth, but I’m not sure how I’d account for drag when the player moves. It would also be difficult to transition between animations, as I want the familiar’s movement to be unpredictable.
-Animation/Lerping?: Animate the familiar when it has a specific action, and use some kind of lerping formula for moving around the player with drag?
-Animation/Physics: Use constraints alongside scripting to keep fluid movement around the player? Transition into animation when specific actions need to be done.
For reference, the base familiar I’m using is a fairy inspired by an old game. It’s rigged and is essentially a pair of wings with a ball of light in the middle.
If anyone has any good threads with info on something like this, could you link me it? Or could I get any advice from someone with more experience than me?
Figured this out! Ended up creating animations alongside Physics. I used an alignposition and alignorientation that follow a ghost brick, which is moved by a script to create a goal for the flying creature.
You could try spring physics applied to movement here is an example:
local position = familiar.Position -- Start position of the familiar
local velocity = Vector3.new(0, 0, 0) -- Initial velocity
local target = goalPart.Position -- The goal part's position (or player's position)
local springConstant = 0.1
local drag = 0.8
game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
local direction = target - position -- Vector from familiar to target
local acceleration = direction * springConstant -- Apply spring force
velocity = (velocity + acceleration) * drag -- Apply drag
position = position + velocity * deltaTime -- Update position
familiar.Position = position -- Update familiar's position
end)
This can give the flying familiar a smoother motion that reacts more naturally to the player’s movement.
Thank you for the input! I’ll definitely try this out when I get the chance, as I plan on testing different kinds of physics stuff and methods for movement.