[SOLVED] How do I spawn 3 criminals out of 10 people?

  • Hello, thank you for reading!

    What I wanted to do is spawn 10 people at random times, but 3 of them should be criminals.

    For that, I created a sprite called "People" and gave it a boolean called "Criminal" and on spawn it's decided (randomly) if it's a criminal or not.

    The spawns are limited by a global variable (invites) that is set by the difficulty and with each spawn it decreases by 1 until it reaches 0 ( so it doesnt spawn anything )

    The problem is: I've tried many things but sometimes the criminal count is wrong, sometimes it spawns more people than it should, it never gets what I want.. Can you help me?

    ( I know the code is messy, sorry about that )

  • Why you don't use 2 sprites one for people and the other for criminals?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I wanted them to be basically the same (same appearance, animations etc), the criminals would do just little things that the people wouldn't. So I thought it would save code and resources if I just did it like this

  • First line look suspiciously. Difficulty = 0 is all time true so all globals are every tick set to what you put in actions.

  • Yes ! That was actually what was making the infinite spawn! I got it all solved now after trying for some while, thanks a lot guys!

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