[Noob] Angle to Position?
I want to get a position based on my yaw angle and a range so that I get set the position to behind me, by lets say 2 metres, how would i do this? I understand this is just maths but at my level of knowledge my code just is not working, here it is please don't be mean i know its shit
I was trying to use sin and cos to get it, but when i run it I am teleported randomly at first(it seems random) and then on a certain path that i have no idea how its getting
Code:
local Me = player.GetByID(1)
function getMyForward()
local Ang = Me:GetAngles().y
local InFrontX = math.sin(Ang) * 200
local InFrontY = math.cos(Ang) * 200
//return Vector( InFrontX,InFrontY,Me:GetPos().z )
local Front = Vector( InFrontX + Me:GetAngles().x,InFrontY + Me:GetAngles().y,Me:GetPos().z )
if Ang > 90 then
Front = Vector( (InFrontX *-1)+ Me:GetAngles().x,InFrontY + Me:GetAngles().y,Me:GetPos().z )
end
if Ang < 0 then
Front = Vector( InFrontX+ Me:GetAngles().x,(InFrontY *-1)+ Me:GetAngles().y,Me:GetPos().z )
end
if Ang < -90 then
Front = Vector( (InFrontX *-1)+ Me:GetAngles().x,(InFrontY *-1)+ Me:GetAngles().y,Me:GetPos().z )
end
return Front
end
Me:SetPos(getMyForward())
