0 votes

Hey, Guys. I am trying to code the enemy script in which for now I am trying to code a feature where the enemy goes in one direction and as soon as it detects a wall it turns around and goes the way. I have coded this according to my knowledge so far in game dev. But every time I run the TestLevel.tscn level the enemy come does from the air and then just flick left and right in its place when I checked the isonwall() function kept switching between true and false even tough there is on wall around it. and when there Is a wall it still keeps going back and forth in a very small space rather than traveling in the other distance. You can check all the scripts and the game files here on my GitHub - https://github.com/k4b00m-Hozaifa/First-Game/tree/master/src

asked Nov 28, 2019 in Engine by k4b00m-Hozaifa (17 points)
edited Nov 28, 2019 by k4b00m-Hozaifa

The assumption you made in the title is probably incorrect: isonwall() probably stays true all the time. In this case it will still flip the direction every frame. You can use print(isonwall()) to see its value in real time.

Try using a RayCast instead.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.