Godot Version
4.5.6
Question
i tried making script that whould make enemy turn arroung when he comes close to a wall edge using raycats also tried adding something that will prevent player from activating it
extends Node2D
@onready var fr: RayCast2D = $FR
@onready var wl: RayCast2D = $WL
@onready var wr: RayCast2D = $WR
@onready var fl: RayCast2D = $FL
var direction = -1
func _process(delta):
position.x += 120 * delta * direction
if not fr.is_colliding():
if not (fr.get_collider() is Player):
direction = -1
if not fl.is_colliding():
if not (fl.get_collider() is Player):
direction = 1
if wr.is_colliding():
if not (wr.get_collider() is Player):
direction = -1
if wl.is_colliding() :
if not (wl.get_collider() is Player):
direction = 1
but the effects of this code are that so it ignores walls ( same effects if i remove if its not a player check )
it sometimes detectes something but it feels really random
