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

rotation between two positions?

Asked by
Exsius 162
8 years ago

Is there any way to get a rotation between two positions

for example:

part points in direction of position2 from position1

Thanks

Exsius :)

0
use lerp XToonLinkX123 580 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

Yes this is possible just read up the wiki, i'll post the link and an example

CFrame Guide

part.CFrame = CFrame.new(part.Position, Vector3.new(0,0,0)) -- this will point at 0,0,0 but still remain at the parts original position
0
Thank you for your help! I truly appreciate it. Exsius 162 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

devSeldom's awnser is a way but there is another way you can use with CFrame.

The other way use a method from CFrame called Lerp this method use two parametre CFrame:lerp(CFrame goal, number alpha) So you'll need to use this like that

local part = workspace.Part
for i = 0, 1, 0.1 do
    wait(0.1)
    part.CFrame = part.CFrame:lerp(CFrame.new(5, 3, 1) * CFrame.Angles(math.pi / 2, math.pi / 2, 0), i)
end

Now you can run it and look at the part, You'll see his mouvement. Hope this help you.

Answer this question