Random actions

0 favourites
  • 2 posts
From the Asset Store
Alot of High Quality Items sound effects for your game!
  • I'm working on very unpredicrable AI for my enemy characters and want them to act randomly in different situations. Simply put, I want to make the enemy to either attack or take few steps backwards when they get close to player. I can make them do that with 50/50 chance by giving them command to randomly jump into states 1 and 2 with "Random(1,2)" command.

    Now I'm wondering how should change the chances between those two, making the jump into state 1 to have 75% percent chance and state 2 to 25%?

    I know this is kinda difficult to explain, and I can't really upload a .capx because the project is so full of things it would take way too long to cut everything unnecessary out.

    I hope someone can help me with this :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There may be more elegant solutions, but you can always (pseudo code, bare with me):

    set a local variable to int(random(3))
    ..local variable <=2 
    ....-> Jump state = 1
    ..local variable = 3
    ....-> Jump state = 2

    It should do the trick.

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