Pong with AI

Get help using Construct 2

Post » Tue Nov 22, 2011 4:17 pm

Hello,
I wonder how to make a game with artificial intelligence. I would like to be able to do to paddle on the right side of herself chased by flying ball.
Sorry for my english

Capx click on 'sciagnij plik' to download
http://delgado88.wrzuta.pl/plik/7lfLNk47H8F/pong

B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Tue Nov 22, 2011 4:46 pm

ok.. i have done it like this.
create an invisible area from the middle to end right or left side, depends on which side you have the ai.
when ball is overlapping the invisible area set enemy "lerp(Enemy.Y, Ball.Y,0.1)"
that will make the enemy follow the ball inside this area. the last bit "0.1" is how fast the enemy will respond on the ball(time), if im correctly.
the only thing i haven't found out yet is how to make the enemy collide with a wall and not go through, because when you lerp an opject then it just ignore everything else.CandyFace2011-11-22 17:50:51
B
20
S
5
G
4
Posts: 61
Reputation: 3,165

Post » Tue Nov 22, 2011 5:15 pm

"lerp(Enemy.Y, Ball.Y,0.1)" what does mean 'lerp' ??
B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Tue Nov 22, 2011 5:35 pm

B
20
S
5
G
4
Posts: 61
Reputation: 3,165

Post » Tue Nov 22, 2011 5:48 pm

Hmmmm I'm not sure I follow you... What do you mean by that?
i set y of enemy lerp(Enemy.Y, Ball.Y,0.1)
enemy paddle dont move.


B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Tue Nov 22, 2011 5:52 pm

Download

that is my modified version of your capx, i have put a comment inside the event sheet.
tell me if you need further help ;)

i hope it explains.CandyFace2011-11-22 18:02:50
B
20
S
5
G
4
Posts: 61
Reputation: 3,165

Post » Tue Nov 22, 2011 6:03 pm

thats amazing pal :) how i can minimal slow down the enemy paddle? (its too fast and he always win ;))
B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Tue Nov 22, 2011 6:37 pm

try to edit the time "0.1" and set it to something else..
between 0.1 and 1 that should slow it downCandyFace2011-11-22 18:37:20
B
20
S
5
G
4
Posts: 61
Reputation: 3,165

Post » Tue Nov 22, 2011 7:13 pm

well paddle is still moving fast but YOU HELPED ME A LOT !!! :)) THANKS:)
B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Tue Nov 22, 2011 8:06 pm

Make the 0.1 something like 0.05 or 0.02 or something ;)
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Next

Return to How do I....?

Who is online

Users browsing this forum: emoticon, KeetonCat, makkancs, Matthew de and 25 guests