I need a function that converts a isometric direction (from a unity isometric tilemap) to a normal one. For example in this image I created waypoints along the track (red line) they dont attach to the tilemap but float above it using linerenderer
so using this
Vector3 targetPosition = trackPositions[currentWaypointIndex];
// Move the locomotive towards the target waypoint
transform.position = Vector3.MoveTowards(transform.position, targetPosition, Mathf.Abs(speed) * Time.deltaTime);
// Calculate the direction to the next waypoint
Vector3 direction = (targetPosition - transform.position).normalized;
I get a direction
I then want to use that to put the train sprite on the track (its actually 36 images) and I need a normal direction in degrees /10 to set the correct image..
EDIT: after using shingo's class this is what I got:
and its not perfect but closer than anything I got so far so I will try to adjust that function .. luck is my only hope at this point..
EDIT2: shingo's solution worked when making this adjustment
public static float YFactor = Mathf.Cos(Mathf.Deg2Rad * 60);
(changed it from 45 to 60) also there was a small bug where it was missing the type (float)
TYTYTYTY
Vector3 forwardVector = transform.forward;
and then just usefloat angle = Vector3.Angle(vectorA, vectorB);
to get the angle between two vectors