Skip to main content
added 233 characters in body
Source Link
Jaxx0rr
  • 598
  • 5
  • 9

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

track

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:

enter image description here

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

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

track

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:

enter image description here

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

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

track

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:

enter image description here

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

added 283 characters in body
Source Link
Jaxx0rr
  • 598
  • 5
  • 9

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

track

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:

enter image description here

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

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

track

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

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

track

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:

enter image description here

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

Source Link
Jaxx0rr
  • 598
  • 5
  • 9

In Unity how do I convert a Vector3 isometric (tilemap) direction to a normal direction in degrees

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

track

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