Need help with tower defense enemy tween rotation

hi im ctg
currently, I and @Saket9 is working on a tower defense system and we making an enemy system
but the enemy in some waypoint when rotation is very weird

here is the video how it weird 2023-04-25 11-39-23_Trim

also here is the code:

  function tweenTable.NextWaypoint()
        if enemy.Parent then
            local WaypointPart = Waypoints[EnemyWaypoints.Value]
            local tweenTime = tweenTable.GetTime(WaypointPart)
            local tweenInfo = TweenInfo.new(tweenTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
            local tweenInfoRotation = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
            
            local tweenRotation1 = TweenService:Create(EnemyRoot, tweenInfoRotation, {Orientation = Vector3.new(EnemyRoot.Orientation.X,WaypointPart.Orientation.Y, EnemyRoot.Orientation.Z)})
            
            local tween = TweenService:Create(EnemyRoot, tweenInfo, {Position = WaypointPart.Position})
            tween:Play()
            tween.Completed:Connect(function()
                tweenRotation1:Play()
                tweenRotation1.Completed:Connect(function()
                tweenTable.TweenComplete()
                    end)
            end)
        end
    end
    tweenTable.NextWaypoint()
end
4 Likes

In tweenRotation1, try making the Orientation negative tweening the CFrame instead to have the same position as the enemy the lookAt be the position of the waypoint

local tweenRotation1 = TweenService:Create(EnemyRoot, tweenInfoRotation, {CFrame = CFrame.new(EnemyRoot.Position, WaypointPart.Position)})
1 Like

nah it wont work bc lookAt is a bad method (if ask why im not try it bc i try already)

1 Like

You could use Humanoid:MoveTo(Waypoint.Position) instead of tweens

imagine high performance, why i need to use humanoid to make td game?

i fixed it now thanks everyone

you should post the solution incase someone in the future has the same issue

kk thx for telling me @Robenhood1416

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