gridmap item translation

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

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 .

I see the problem now .
After using :
Point = Grid.world_to_map(ray.get_collision_point())
I need to :
Grid.map_to_world(Point.x,Point.y,Point.z)

Sorano Sakura | 2021-06-25 06:21