I’ve been wondering if there is a way to make a smooth turn by using Tween Service
In the Image bellow you can see i have 3 Points (A , B , C) and i want my part(the Green Cube) to move from Point A to Point B and from Point B to point C. That alone is easy with Tween Service but i wanna know if there is a way for it to turn smoothly (basically follow the Black Line) and also turn the cube itself in the process to face towards the direction its turning to (the purple line on the cube is the direction its facing)
does anyone know if this is possible using tween service and if not is there any way to do it?
I don’t think making these curves with tween service is possible, though you can experiment with lerping, you can either use trigonometry, basically what @hunder305 recommended, or use bezier curves. But both require some type of lerping/Run Service loop.
Heres an example with Bézier curves, you also need a control part, because Bézier curves require 3 or more points,
local RunService = game:GetService("RunService")
local part = workspace.Part
local start = part.Position
local control = workspace.Control.Position
local target = workspace.Target.Position
local duration = 5
local startTime = tick()
RunService.Heartbeat:Connect(function()
local elapsed = tick() - startTime
local t = math.clamp(elapsed / duration, 0, 1)
local position = (1 - t)^2 * start
+ 2 * (1 - t) * t * control
+ t^2 * target
part.Position = position
if t == 1 then
return
end
end)
I think this is more simple than Dot and Cross product, though Dot and Cross also aren’t that hard to understand. Watch some general YouTube tutorials about Dot and Cross, you’ll get what they do, but from what I understand:
Dot: Measures how much one vector points to another
Cross: Finds the vector perpendicular to the 2 provided(Only in 3D space.)