Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to slide vector3 point1 to vector3 point2 on line?

Asked by 6 years ago

I don't really need the sliding itself but to get the point2 on the line which is .2 studs far from point1, so I wrote this code:

local Pos2 = Vector3.new(Pos1 + (Direction.unit * .2))

where Direction is lookVector, so I need Pos2 to be on Direction line .2 studs far away from Pos1 but in the code above the output returns Pos2 as (0,0,0)

1 answer

Log in to vote
0
Answered by
thesit123 509 Moderation Voter
6 years ago

Use TweenService for this:

local TweenService = game:GetService("TweenService")

local part = workspace.Part -- The object

local goal = {}
goal.Position = Vector3.new(10, 10, 0) -- Position

local tweenInfo = TweenInfo.new(5) -- Time in seconds it will take

local tween = TweenService:Create(part, tweenInfo, goal)

tween:Play()
Ad

Answer this question