#help for simple enemy ai gdscript
5 messages · Page 1 of 1 (latest)
could also be collision layer problem
so var derect = int / func onready() derect = 1
you should probably put that into the physics process, but i don't think that should make it not work at all.
are you sure that your raycasts have the proper length and collision layer?
also note that the raycast by default only hits shapes if it hits them from outside, so if it moves into the wall it might be that it won't detect the collision.
You are 'shadowing' the derect variable by using 'var' in the _process function (in lines 10 and 12) to create a local version of it. I think as a result if either raycast is colliding the local version of the variable will be used in line 14 but if they are not no local version will be created and so the version defined in line 4 will be used instead, which never gets its value changed from being 1. Basically you need to take out the 'var' in lines 10 and 12.