(SOLVED) AI Movement stuck after target exits the screen

daysixs

  • Posts: 5
Hi everyone. I'm currently making a short Pong Clone where I implement an AI feature into it. Everything's been going smoothly so far with the AI's movements but when the ball exits the screen (aka into the goal), the AI paddle suddenly stops moving/static in place and doesn't repeat the same behavior like when it was before.

Below are the codes that I have done for the AI's behavior. Please help a poor soul out into figuring out where the problem is...

« Last Edit: October 27, 2020, 01:34:10 am by daysixs »

Luyren

  • *
  • Posts: 2435
My guess:
1- Your ball is not set to always active, so it gets "stuck" once it goes off screen.
2- Your actor is constantly tracking the position of your stuck ball.
3- You are only calling "refresh" once when the actor is created.

You should kill your ball when it is offscreen, and once a new ball is created, call "refresh" again for your AI actors.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

daysixs

  • Posts: 5
Hey Luyren! I've made a specific exit behavior for the ball which looks like the first picture attached.

I've tried a few problems to solve it (adding a refresh behavior in the ball's events, making it active always) yet I can't seem to pinpoint where it went wrong. I'd also like to note that I've set an event where the ball is always created whenever it exits the screen so should I fix it on the paddle's side or the ball's side?

The second attachment is linked to the ball that acts in the AI scene.

Luyren

  • *
  • Posts: 2435
As I said, you should kill the ball after it leaves the screen (which the code you showed doesn't do), and you need to call the "refresh" custom event again for your AI actor after the ball exits the screen. You could achieve that by doing "If Target is not alive, call refresh for this behavior" or something along those lines.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

daysixs

  • Posts: 5
You saved me, Luyren.

Thank you for helping me think out of the box! I was stuck working on the same problem at the same actor when it was just something as simple as that and BOOM, it's working like a charm!