How do I Create Platformer AI?

  • I want to create a an AI where an enemy moves from side to side. How Can I do this I tried use the sine behavior but I don't know how to make it go further distances.

    Thanks!

  • If you mean to have the enemy move back and forth between 2 points (as in from one end of a platform to the other and back).

    A simple way is to put an invisible object at each end of the platform (or patrol line) and have the enemy reverse direction when he collisions with said object.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • First you need logic. Then apply the logic.

    From side 2 side, i suppose there are platforms between the sides.

    Set the controls in the platform properties to custom. Now we have to code every move it will make.

    • When there are no decisions to make at its current position.

    Just keep going in the current direction.

    To do that you need a instance variable that holds the direction.

    Use the action 'Simulate control' to simulate left/right according the instance variable.

    -When there is a wall in the left or the right.

    Platform has a condition 'Is by wall'. Change the instance variable to reflect the change in direction.

    -When it comes to a place where it has to decide to jump on or walk under a platform.

    Place invisible object on those places where a decision is needed. Detect an overlap.

    Pick a random (expression choose(0,1)). If 0 jump

    -When it comes to a place where has to decide to just fall off or to jump to another platform.

    Same system, place invisible objects. Detect an overlap.

    Pick a random (expression choose(0,1)). If 0 jump

    And so on. Build the logic. Apply the logic.

    -When it is seeing the player

    To look for the player you can use the Line-of-sight behavior.

    Calculate (based on x differences) what direction the player is.

    Change the direction instance variable according.

    Eventual look if the player is jumping, if jumping run other direction.

    And so.....

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