Need Help with super simple AI


am new in Defold and im trying to learn AI
i want to create AI that move randomly and when i touch the screen it will move the place i touch
i want it to have to state ::
“MOVING” that when he move around
“IDLE” that in between
is there a function that will tell when my object stop moving ???

1 Like


You will get a message with action.released set to true, so you can check for it in on_input() :wink: something like that: (I wrote it on phone on the go, so treat it like a pseudo code) :wink:

if action_id == hash("mouse_click") then
      if action.pressed then
          self.state = "Moving"
      else if action.released then
          self.state = "Idle"


If you use go.animate() you will get a callback when the animation/movement is done.

1 Like


Yes, @britzl got better understanding on what you were trying to achieve probably! :grin:



There’s also inspiration to be found here in this example:

1 Like


Thanks for the fast reply
When I get back to my computer i will try and tell if it work