Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

3 comments

0

forgot to put in i=i+1 in line 20

0

what do you want to make, also what's the dirX, dirY, dirZ in your output

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) )

1 answer

✓ Accepted answer

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)

1 comment

0

thanks! works great

This discussion is preserved as it was. New answers, comments, and votes are closed.