How to determine TileMap as a wall?

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

Hi everyone :slight_smile:
I’m currently making a 2D stealth game, including rooms, furniture(TileMap) and guards (KinematicBody2D).

I’m using Navigation2D, and get_simple_path to make the guards patrol around, but when they collide with any furniture- they get stuck.

I thought about a few ways to fix this, but the easiest one yet is to make the guards treat the furniture as walls, and use is_on_wall statement.
how do I do that?

And if you have a better idea, I would love to hear it, beacause I still havn’t figured out how to walk around the furniture. The best idea I’ve got is to make the guards choose a different destination.

Thank you all in advanced!

I think you cannot use isonwall because it determines something as a wall only for two directions while a furniture can be touch in any direction.

What are your using for ground?

Traumaticbean | 2020-05-03 04:04

Sorry it took so long for me to reply.
For the guard I’m using motion as Vector2, and move_and_slide().
here’s the script for the guard:

extends "res://Script/Character/NPCs/"

# Inheriting the following:
#const SPEED = 50
#const MAX_SPEED = 300
#const FRICTION = 0.25  # the time to get from MAX_SPEED to 0.

onready var navigation = get_tree().get_root().find_node("Navigation2D", true, false)
onready var destinations = navigation.get_node("Destinations")

var motion
var possible_destinations
var path =[]

export var minimum_arrival_distance = 5
export var walk_speed = 0.5

func _ready():
	possible_destinations = destinations.get_children()

func _physics_process(delta):

func make_path():
	var new_destination = possible_destinations[randi() % possible_destinations.size()     -1]
	path = navigation.get_simple_path(global_position ,     new_destination.global_position , false) 
func navigate():
	var distance_to_destination = global_position.distance_to(path[0]) 
	if distance_to_destination > minimum_arrival_distance:

func move():
	motion = (path[0] - global_position).normalized() * (MAX_SPEED * walk_speed)
	if is_on_wall():
		rotation_degrees += 90 

func update_path():
	if path.size() == 1 :
		if $Timer.is_stopped():

func _on_Timer_timeout():

drorya | 2020-05-13 05:49