0 Favourites

How do I make a fighting CPU?

  • 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.

  • 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.

  • 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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)