Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Proper Movement for Isometric Game

Discussion in 'Scripting' started by Nathan_D, Jun 11, 2018.

  1. Nathan_D

    Nathan_D

    Joined:
    Oct 10, 2013
    Posts:
    31
    Hi,

    Sorry for such a basic question, but I am stumped.

    I'm making an isometric pixel game that exists in 3D space. So basically try to imagine a doll-house of sorts, where walls are actually 2D sprites arranged together to create 3D geometry.

    All my character sprites are rotated 315 degrees on the X axis,and my floor is rotated 45 degrees on the X axis. I'm therefore using both the Y and Z values to move my player up and down. But my movement vector math isn't correct. When I make the character move, I want him to move along the floor so he won't slowly float into the sky or sink into the floor. But he sinks into the floor slowly as he moves up into the background.

    What is the correct vector math when a sprite is rotated 315 degrees on the X axis and wants to move using the Y and Z axis equally, so he moves in a straight line?

    Scene-test.png

    game-test.png
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Maybe your game really needs to the angles you've describes, but... Is there a reason you can't keep everything at proper right angles, and just angle the camera 45'? That seems equivalent in terms of appearance, and it seems it would dramatically simplify a lot of other things...
     
    Nathan_D and Lethn like this.
  3. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    It does seem like he's trying to re-invent the wheel to be honest, why do all that complicated maths when he's keeping everything in an isometric view anyway?
     
    Nathan_D likes this.
  4. Nathan_D

    Nathan_D

    Joined:
    Oct 10, 2013
    Posts:
    31
    Thanks for the replies.

    I understand what you mean about the weirdness. But my game has point and click mechanics which act as raycasts from screen to camera. So if the camera was tilted 45 degrees it would really mess up the accuracy of the raycast, so the simpler solution was to keep camera non-rotated. I would assume the fix for this is straight forward, but I'm stuck. Is is difficult to make the character move along the angle of the floor, meaning the character is pretty much moving diagonally at a 45 degree angle?
     
  5. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    I think you're going about this in an unnecessarily complicated way and I know of a way that could help you out I think and it uses modern techniques rather than any particular complicated maths aside from Cartesian Co-ordinates.

    https://forum.unity.com/threads/mouse-click-movement-with-isometric-artwork.515059/

    I did some extensive research on this topic awhile back because I got very curious about isometric games since I like the Baldur's Gate series and so on so much. It turns out there's a modern method that the Pillars of Eternity/Tyranny devs and so on use for their games and it works really well. Not 100% sure this is what the do but they do use the unity engine so I experimented a lot and found out how to get a project up with basic movement including camera movement.

    Now, this method using the navmesh and 3D characters, but if you assign an agent to an empty with a sprite I think you could replicate this for your game and you will have a much easier time with movement. Please try it and let me know if it works, I've tested it myself and it works fine but you should see if you can adapt it to your game idea.

    With this method you can quite easily mix and match 2D and 3D elements while keeping them all isometric, background art for example in the method that I've looked at is 2D and then the Pillars of Eternity/Tyranny devs have used 3D characters and 3D movement to deal with all their character stuff.

    You don't have to have the map rotated either, you could just keep it normal for your game, the degrees for the camera should all work out the same, in which case, you wouldn't need to use cartesian co-ordinates.
     
    Nathan_D likes this.
  6. Nathan_D

    Nathan_D

    Joined:
    Oct 10, 2013
    Posts:
    31