- Home /
Get Camera's Vector(1,01)
So I have a code that returns world forward, world (1,0,1) and etc. But I don't know how to get camera's (1,0,1) and etc. Vectors. Please help
Vector3 SwipeAngleTest(float angle)
{
if (angle < -157.5 || angle > 157.5)
{
//Debug.Log("Left");
return -Vector3.right;
}
else if (angle < -112.5)
{
//Debug.Log("Down Left");
return new Vector3(-1, 0, -1);
}
else if (angle < -67.5)
{
//Debug.Log("Down");
return -Vector3.forward;
}
else if (angle < -22.5)
{
//Debug.Log("Down right");
return new Vector3(1, 0, -1);
}
else if (angle < 22.5)
{
//Debug.Log("Right");
return Vector3.right;
}
else if (angle < 67.5)
{
//Debug.Log("UPRight");
return new Vector3(1, 0, 1);
}
else if (angle < 112.5)
{
//Debug.Log("Up");
return Vector3.forward;
}
else
{
//Debug.Log("up left");
return new Vector3(-1, 0, 1);
}
}
I'm can't quite understand this "But I don't know how to get camera's (1,0,1)". Were you not able to arrive at the else statement that should log Vector3(1, 0, 1)? Or could you provide more context to your question?
@Tinglee82 There is transform forward and right,right? That state the local forward. But how do I get transform's diagonal axis? like up and right(vector(1,0,1)) of relative forward
By "transform's diagonal axis", are you referring to the forward direction of the camera? Sorry I still can't understand your use case, or at least which parts of your code are not working.
Answer by conguerror · Jun 20, 2021 at 05:32 PM
return (transform+new Vector3(1,0,1)).Normalize()