How do I make a fighting CPU?

Get help using Construct 2

Post » Thu Sep 01, 2016 7:11 pm

How do I make a CPU, that fights against a player the same way one fights in Smash Bros. and can dodge, shield, and attack. Mostly attack.
B
25
S
6
G
4
Posts: 173
Reputation: 3,928

Post » Thu Sep 01, 2016 7:51 pm

1 problem at a time...

You can simulate button presses, when certain conditions are met.

For example... If the CPU is 50 pixels from the player, simulate attack button. (or roll then attack)
I would highly recommend having a randomness element added, so it picks from a list, that way it seems to have a mind of it's own.
Eat ALL THE BACON!
B
45
S
17
G
3
Posts: 290
Reputation: 4,993

Post » Thu Sep 01, 2016 9:05 pm

No such thing as AI in this engine. You gotta build it yourself. Have the character calculate its distance to player and act accordingly. Randomize variables and determine their next events by the resulting numbers. Simulate movement by giving the character a movement behavior, but disable its default controls so player can't control them.

From my experience making AI is a very long process of hit and miss. You gotta start simple and add to that. First start by making the enemy move and stop when required. Then make them jump randomly at certain distances. Then add animations and events for them to simulate attacks. One piece at a time.

One good tip I can give to you is to make a Hitbox (the sprite that has the movement behaviors and such, and is invisible) and Animation sprite (the actual character and its sprites) seperately. Pin the Animation sprite to Hitbox and make the Hitbox invisible.
B
21
S
7
G
4
Posts: 231
Reputation: 3,470

Post » Thu Sep 01, 2016 9:39 pm

Make sure you use timers on certain skills. You don't want your NPC casting its best spell every 2 seconds. You could also add a "Hard" or "Easy" mode and adjust those timers accordingly.
B
56
S
15
G
13
Posts: 825
Reputation: 17,643


Return to How do I....?

Who is online

Users browsing this forum: blissfulwizard, DevinMurray, RobertMKD and 15 guests