Need help with AI programming!

Get help using Construct 2

Post » Fri Nov 01, 2013 1:39 am

I am making a game similat to Pong, and I want to program the AI to try and match the ball's Y axis, but I don't know how to do that. Can someone please help me or direct me to a tutorial that can help?
B
12
S
2
Posts: 4
Reputation: 1,562

Post » Fri Nov 01, 2013 4:34 am

Use [Event -> System -> Compare two values]

ball.Y >= computer.Y -> [Action] Add 5 to computer.Y
ball.Y < computer.Y -> [Action] Subtract 5 from computer.Y

You will have to adjust the value 5 to something that works for your game...

not much else too it :)arontwose2013-11-01 04:39:49
B
8
S
3
G
1
Posts: 34
Reputation: 1,395

Post » Fri Nov 01, 2013 9:49 am

I believe that the above would be executed each tick, therefore you really should consider adding a "Every X seconds" condition to the event.
Something like 0.05 should do nicely (done 20 times per second).

Also, if you'd like something more complicated (with the paddle accelerating, instead of merely moving), you could try a custom movement behaviour and compare the axial speed and coordinates, if speed towards the needed point is below the maximum allowed, then add acceleration to the paddle towards it every x seconds.
B
10
S
1
Posts: 163
Reputation: 1,436

Post » Fri Nov 01, 2013 12:27 pm

Here's an example I made for you

https://www.dropbox.com/s/07fu8bvphfc9ll2/pong%20example.capx
B
8
S
2
Posts: 15
Reputation: 630


Return to How do I....?

Who is online

Users browsing this forum: PROxMTswatTR, sean080 and 39 guests