How to use stepify in an isometric grid

CauseTripodCauseTripod Posts: 13Member

I'm using stepify for an object that I'm dragging in an isometric grid however stepify isn't exactly my solution.

One way I thought of using stepify was to have two stepify functions one that has a vertical offset at the specific x value where it is needed. However I don't know how to add an offset to stepify without adding random values as it still needs to be represented by my mouse position.

Or there might be a better solution.

Any help is appreciated!


Tags :

Answers

  • duaneduane Posts: 271Member
    edited May 14

    If you're using an actual TileMap, you can use it to get the discrete steps:

    func rounder(pos:Vector2) -> Vector2:
        var map = get_node('TileMap')
    
        var p1 = map.to_local(pos)
        var p2 = map.world_to_map(p1).round()
        var p3 = map.map_to_world(p2)
        var p4 = map.to_global(p3)
        p4.y += round(map.cell_size.y / 2.0)
    
        return p4
    
  • CauseTripodCauseTripod Posts: 13Member

    Hey, thanks for your reply.

    I am using a TileMap however your solution seems not to work unless I've done something wrong

  • CauseTripodCauseTripod Posts: 13Member

    Never mind, I did something wrong but it works now!

    Thanks a lot!

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file