+1 vote

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
in Engine by (842 points)
edited by

1 Answer

0 votes
Best answer

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.

by (842 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.