Renderstepped fps issue

I’ve got an animation from a friend of mine to use, the animation was build for 60fps and when its over 60 fps animation becomes weird. I have read on some devforum posts that I have to multiply by dt - delta time but im not sure what to multiply.

    local playerChar = self.Owner.Character
    if not self.Owner.Character or not self.Instance.PrimaryPart or not self.Owner.Character.PrimaryPart or not playerChar:FindFirstChildOfClass("Humanoid") then
        return
    end

    local target = self.Owner.Character.PrimaryPart.Position + self.Offset
    local Next0 = (self.Position:Lerp(target, 0.1) * Vector3.new(1, 0, 1))
    local Next1 = (self.Position:Lerp(target, 0.3) * Vector3.new(0, 1, 0))
    local Next = Next0 + Next1
    local moving = playerChar:FindFirstChildOfClass("Humanoid").MoveDirection.Magnitude > 0
    local now = tick()
    local angle = (now + self.Phase) % (math.pi * 2)
    local animation = CFrame.new(0, 0.25, 0)
    local twist = CFrame.new()

    if self.Flying then
        local cframe = CFrame.new(0, 3, 0)
        local anim = CFrame.Angles(math.rad(math.cos(angle * 4)) * 8, 0, 0)
        local anim2 = Vector3.new(0, math.sin(angle * 4) * 0.5, 0)
        animation = cframe * anim + anim2
    end

    if moving and not self.Flying then
        local animationIntensity = math.clamp((ToVector2(Next) - ToVector2(target)).Magnitude, 0, 4.5) / 4.5
        local y = math.abs(math.sin(angle * 10)) * 3 * animationIntensity
        local r = math.rad(math.sin(angle * 10)) * 20 * animationIntensity
        animation = CFrame.new(0, y, 0) * CFrame.Angles(0, 0, r)
    end

    if moving then
        twist = CFrame.new(Vector3.new(), self.Owner.Character.PrimaryPart.CFrame.LookVector)
    else
        twist = CFrame.new(Vector3.new(), ((Next0 * -1) + (self.Owner.Character.PrimaryPart.Position or Vector3.new())) * Vector3.new(1, 0, 1))
    end

    self.Twist = self.Twist:Lerp(twist, 0.1 * 0.5)
    self.Animation = self.Animation:Lerp(animation, 0.3 / dt)
    self.Position = Next

    if self.ModelWrapper then
        self.ModelWrapper:SetCFrame(CFrame.new(self.Position) * self.Twist * self.Animation)
    end

here is the animation, if you could help me out would really appreciate.

2 Likes

Where you could incorporate delta time would be in the self.Twist and self.Animation

self.Twist = self.Twist:Lerp(twist, 0.1 * 0.5 * dt)

self.Animation = self.Animation:Lerp(animation, 0.3 * dt)

It might seem slow at first so mess with the values until you get your desired effect

1 Like

Keep in mind that any line that is either dealing with change and you are multiplying it by a scalar value multiply it by delta time too

1 Like

that doesnt resolve it sadly, it makes the animation even worse

1 Like

Okay so lets take it slow then what does it currently look like and what are you trying to make it do?

1 Like

i will send u a video in a second how its looks on 60 fps and how it looks on 240

1 Like

if self.Flying then
    local cframe = CFrame.new(0, 3, 0)
    local anim = CFrame.Angles(math.rad(math.cos(angle * 4 * dt)) * 8, 0, 0)
    local anim2 = Vector3.new(0, math.sin(angle * 4 * dt) * 0.5, 0)
    animation = cframe * anim + anim2
end

if moving and not self.Flying then
    local animationIntensity = math.clamp((ToVector2(Next) - ToVector2(target)).Magnitude, 0, 4.5) / 4.5
    local y = math.abs(math.sin(angle * 10)) * 3 * animationIntensity * dt
    local r = math.rad(math.sin(angle * 10)) * 20 * animationIntensity * dt
    animation = CFrame.new(0, y, 0) * CFrame.Angles(0, 0, r)
end

So I noticed these if statements handle the bobbing and the animation rotation mainly

1 Like

thanks for trying to help me out, the issue still persists though

do you mean this when you say multiply by delta time?

RunService.RenderStepped:Connect(function(DeltaTime : number)
	DeltaTime = math.min(DeltaTime*60, 1)
end)

or did i misunderstand something?

Yeah now what you wanna do is increase the multiplier on the shaking and the bobbing