Isometric movement always off

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Footurist

I have a sprite which is 100% isometric. I move it with a vector of 0, -1 converted to isometric, which gives 1, -0.5. However, when I move it a certain distance, you can see it’s clearly not moving along the exact isomteric axes. It will be off a bit. So I looked at the demo from GitHub about Isometric 2D and I noticed, that the y axis isn’t exactly 60 degrees shifted. It’s 63.something degrees (for the sprites I mean). I took the standard icon and some other sprites and lined them up with 60 degrees and it was just off. Then I created a graphic where both axes are rotated by an extra 3.5 degrees and everything lined up perfectly. What is going on there?

static func to_iso(cartesian):
	return Vector2(cartesian.x - cartesian.y, (cartesian.x + cartesian.y) / 2)

extends Node2D

var speed = 300
var motion = Vector2()

func _process(delta):
	var dir = Vector2()
	if Input.is_action_pressed("ui_up"):
		dir += Vector2(0, -10)
	if Input.is_action_pressed("ui_down"):
		dir += Vector2(0, 10)
	if Input.is_action_pressed("ui_right"):
		dir += Vector2(10, 0)
	if Input.is_action_pressed("ui_left"):
		dir += Vector2(-10, 0)
	motion = dir.normalized() * speed * delta
	motion = Utility.to_iso(dir)
	# $Illusion.position += motion
	$Illusion.position += motion
	print(motion)
:bust_in_silhouette: Reply From: Footurist

Turns out, that I used a wrong conversion function. GDQuest made a video about this topic and used the factor 2 for the conversion, which, now obvious, only works for orthographic projection with a width / height ratio of 2:1. For true isometric projection you’d have to use sqrt(3).He didn’t point that out clearly, so that this mistake can easily be overseen and sneak in.