I’m trying to remake pong (as an educational exercise), so far I’ve found tutorials more for 2 (keyboard) players using WASD + CURSOR… but I’m trying to make a 1 player vs Computer version.
I tried this - LOL
But it roams around, chasing the ball.
I also lowered the speed also, as I don’t want to have the perfect AI player…
How best to do this please?
Hi, it seems there are different ways to do this. For some background about the original pong game:
And here a solution that is suggested often and seems to work (if ball is above paddle, move up; if ball is below paddle, move down)
Most simple solution is to for example create global variable called RNG
Now you make event
Ball distance to Player2 is below 50 pixels (adjust distance to your needs i would go with going length of half of whole field)
Change global variable RNG set to RandomInRange(0,5)
Now you copy your event from your screenshot above and paste it over in 3 events
in 1st event
Global Variable RNG is higher or equal to 0
Global Variable RNG is lower or equal to 3
Here you add your action from screenshot BUT
You go for Player2.AngleToObject(Ball.Y)+RandomInRange(-15,+15)
Again numbers here need to be adjusted
Add action from your screenshot and in length in pixels go RandomInRange(200,400) instead of just 400
You do same exact thing for 2nd event with condition
Global Variable RNG is equal to 4
And in action you do same exact thing where you give it lower random in range values
So if you for example had in above event
You would go with
Global Variable RNG is equal to 5
Here you simply paste what you have on screenshot
RNG variable will pick random number from 0 to 5
So you have bigger chances to get number from 0 to 3
Which in action will make AI make dumb move
And lower chance if RNG will be 4 where enemy make less dumb move
And same chance as above if RNG will be 5 for enemy to make spot on move
I hope you get the idea
Thanks @Drona & @ZeroX4. I got it working with your help.