Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | JeremiasDev |
Hello, I created an AStar pathfinding with the video from GDQuest, then I did when you click on a character and then an object, in this case a tree. Then the character runs to the tree. But the tree is not recognized as an obstacle. I used in the script:
extends Node2D
onready var your_tile_map = get_parent (). get_node ("TileMap") # The path for your actual TileMap
func _ready ():
var grid_position = your_tile_map.world_to_map (self.global_position) # Converting position
your_tile_map.set_cellv (grid_position, 0) # Setting a collision tile
and in the script it creates a tile in the correct position of my tree, but the tile is not recognized as an obstacle for whatever reason. The ID is perfect, ID 0 stands for the object where there is an obstacle. So if I put the obstacle on the tree myself by hand then it works without problems but if I do not do that in the script.
Does anyone know what I mean and has a solution? if so it would be super nice!