Godot Version
4.2.2
Question
I have these enemy nodes that are trying to squeeze diagonally between a wall tile and a barrel tile, both of which have a null navigation polygon.
This script is what my tilemap uses. Map layer 1 is for walls and map layer 2 is for objects. The barrel is an object:
extends TileMap
func _use_tile_data_runtime_update(_layer, coords):
if coords in get_used_cells_by_id(1) or coords in get_used_cells_by_id(2): return true
return false
func _tile_data_runtime_update(_layer, _coords, tile_data):
tile_data.set_navigation_polygon(0, null)
My movement func in my script for the enemies:
func move():
await get_tree().physics_frame
if not attacking:
if target:
nav_agent.target_position = target.global_position
change_facing(target.global_position)
else:
nav_agent.target_position = home_pos
change_facing(home_pos)
var current_agent_pos = global_position
var next_path_pos = nav_agent.get_next_path_position()
var new_velocity = current_agent_pos.direction_to(next_path_pos) * move_speed
nav_agent.set_velocity(new_velocity)
move_and_slide()