0 votes

hi , i wanted to know the translation or the position "item" , on used cell , from gridmap node .

func _input(event):
if event is InputEventMouseButton and event.pressed and event.button_index == 1:
    Mouse_Position = get_viewport().get_mouse_position()
    var from = camera.project_ray_origin(Mouse_Position)
    var to = from + camera.project_ray_normal(Mouse_Position) * Ray_Length
    ray.transform.origin = from
    ray.cast_to = to
    Point = Grid.world_to_map(ray.get_collision_point())
    # Point = Grid.map_to_world(translation.x,translation.y,translation.z)
    print(Point)

if i use :

Point = Grid.world_to_map(ray.get_collision_point())

i get (0,0,0) in used cell and empty too .

and if i use this :

Point = Grid.map_to_world(translation.x,translation.y,translation.z)

i get (1,1,1) and in used and empty cell , how can i get the position or the translation of item in gridmap node ? i was expect something like (1,0,1) or (4,0,8)

and thank you .

Godot version 3.3.2
in Engine by (22 points)

I see the problem now .
After using :
Point = Grid.worldtomap(ray.getcollisionpoint())
I need to :
Grid.maptoworld(Point.x,Point.y,Point.z)

Please log in or register to answer this question.

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.