Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Halflove |
Hey there,
Firstly I’d like to say that I’m still very new to this engine and I am experimenting with some of the 2D functionality. I found myself at a bit of a roadblock that had me scratching my head all night. Keep in mind my code is a bit messy as I have been, like I said, experimenting with GDScript.
Here is a clip of the issue: https://i.gyazo.com/f7c9d00bd1f806ab93b45e1b405a4390.mp4
As you can see the enemy AI gets completely while trying to navigate the generated path between itself and the player. My best guess at what is causing this is that I am generating a new path for every tick which is causing the enemy to get stuck. However, after further investigation, that doesn’t seem to be the case. Also, my tilemap is set up correctly so that is not something that needs to be considered either.
Below I have posted the pastebins relating to the enemy’s AI.
Enemy.gd: extends KinematicBody2Dvar motion: Vector2 = Vector2.ZEROvar speed = 110 - Pastebin.com
EnemySM.gd: # Extend the State Machine scriptextends "res://StateMachine.gd"# Ready fu - Pastebin.com
StateMachine.gd: extends Nodeclass_name StateMachinevar state = nullvar previous_state = - Pastebin.com
Thank you for your help in advance!