Simple angle calculation is giving me headaches..

Hello everyone,

I’m making a system for ingame road placement, where I create road segments between two points of a list of points and put them together.

Now I have a problem when calculating an angle between 2 road segments, to check if both segments form a straight line or are curved. In other words, I need to get an angle from two lines, each line defined by a Vector3.

Help would be very appreciated,
WRZ

Found the solution to it in this thread: Angle between two lines in 2D - Unity Answers

Code that works for my project and gives me a Degree between 0 and 180 is following:

Vector2 A = new Vector2(0, 0);
		Vector2 B = new Vector2(0, 1);
		Vector2 C = new Vector2(1, 2);

		float angle = Vector2.Angle(B-A, B-C);

Whenever that value is 180, I know that those 3 points are forming a straight line.

Cheers and thanks, WRZ