Need Help with super simple AI

#1

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
and
“IDLE” that in between
is there a function that will tell when my object stop moving ???

1 Like

#2

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"
       end 
end
0 Likes

#3

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

1 Like

#4

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

0 Likes

#5

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

1 Like

#6

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

0 Likes