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

how to move an object in 3d by using only angles?

Asked by 3 years ago

what math methods should i use to get the direction?

i=0
m=1000

angX=script.Parent.Orientation.X;--90
angY=script.Parent.Orientation.Y;--0
angZ=script.Parent.Orientation.Z;--0

dirX=math.cos(math.pi*angX/180)
dirY=math.sin(math.pi*angY/180)
dirZ=math.tan(math.pi*angZ/180)

print(dirX)
print(dirY)
print(dirZ)

repeat
    wait(2.5)
    print('wow')
    workspace.launchingparttest.Position =Vector3.new(workspace.launchingparttest.Position.X+dirX,workspace.launchingparttest.Position.Y+dirY,workspace.launchingparttest.Position.Z+dirZ)

until i>=m
--doesnt move

i tried switching around the cos sin tan log methods but no sucess

0
forgot to put in i=i+1 in line 20 fullguyblox3 69 — 3y
0
what do you want to make, also what's the dirX, dirY, dirZ in your output Xeqro 20 — 3y
0
i wanted to make a rocket thing where the angle slowly decreases so i made this test first because i didnt know how to get the direction in 3d also the dirX,dirY,dirZ are the directions that i made like in 2d e.g( dirX=math.cos(ang) dirY=math.sin(ang) ) fullguyblox3 69 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

Why don't you use CFrame? Part.CFrame.LookVector is might be what you are looking for and is easier to operate with. I don't know these methods you are using very well, but CFrame is a very good solution and it returns pretty much same resulst as you would expect with your method.

i=0
m=1000

lookVector = script.Parent.CFrame.LookVector
print(lookVector)

repeat
    wait(2.5)
    print('wow')
    workspace.launchingparttest.Position = workspace.launchingparttest.Position + lookVector

until i>=m
--doesnt move

Also I am not sure but the reason why your method is not working is bc roblox uses Tait–Bryan angles instead of Euler angles (it's said here)

0
thanks! works great fullguyblox3 69 — 3y
Ad

Answer this question