Fastloops, Spread IDs, and RNG need help

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hey everyone,

    I have been looking up Fast loops and spread IDs to give each instance of the same enemy to be unique, but they seem to act on eachother's Y position when it comes to gravity.

    I used fastloops to make it so enemies will have gravity, and have it set that every couple seconds, the enemy will jump, and when they jump, they will move towards an object, but will not move towards the object when on the ground. Whenever one instance of the enemy is placed, it works fine, but when there are multiple that are spawned in on different heights, they will constantly move towards the object unless they all are touching the ground. Any idea how I fix this? I gave an alterable value that is ID and used the Spread value function on it to make them unique, but it seems to do nothing.

    And another problem is I can't seem to find a RNG to give each enemy a random time and height they will jump at.

    All help will greatly be appreciated.

  • Awesome that you've investigated this a little on your own already.

    The first two things you need to code are:

    Always:
    -> Spread Value "ID" in "Enemy"

    Always:
    -> Start Loop "Enemy ID" NObjects "Enemy"

    These need to be in two separate lines of code - bug in mmf2.

    Then, anytime you reference the enemy:

    OnLoop "Enemy ID"
    + LoopIndex "Enemy ID" = ID of "Enemy"

    This will give you the uniqueness you need for every instance of the enemy.

    For example:

    OnLoop "Enemy ID"
    +LoopIndex of "Enemy ID" = ID of "Enemy"
    -> Set EnemyTime to Random(7)+1
    -> Set EnemyHeight to Random (5)+1

    Anything more specific, post your mfa example

    Please login to see this link.

  • I have

    On Loop "EnemyID"
    +"ID of "Enemy" = LoopIndex("EnemyID")

    but I don't know where to put it or what to do with it, The other part of the code that has it read when to move when the enemy is off the ground is:

    Grav of "Enemy" <> 0
    ->Start Loop "Gate Check"

    On Loop "Gate Check"
    +X position of "Enemy" < X("Gate Object")
    -> Set X position to "Enemy" X position +5

    On Loop "Gate Check"
    +X position of "Enemy" > X("Gate Object")
    -> Set X position to "Enemy" X position -5

    Where should I put the SlimeID stuff? I tried different places, but it messes up. Whenever one enemy has a different Grav than 0, They all can move in the X position, and I don't want that.

  • Here is what I mean. I put the OnLoop and Loopindex code whenever I reference the Slime, but nothing happens. If you take that out, it will work, but the slime will move whenever at least one is in the air, which shouldnt happen. If there is only 1 slime, it works fine, but when there are multiple, then they do this. If all the slime are spawned on the same height, then it will work fine, but if at least one is in the air, they all will be able to move towards their desitnation, which presents a problem, because I will have multiple spawning in at different times and different heights, inevitably making them able to move freely as others spawn in. Where did I go wrong?

  • Still not sure what you're trying to do with "GateCheck" but here are a couple of problems I see.

    Lines 1 and 5 have the same code.

    You can't put 2 On Loops in the same line. (That's why only 1 is red).

    If you have a "during loop 1, start loop 2" you can toggle an alterable value or use a flag to identify which active you're addressing.


    For example:

    Always:
    ->Spread Value 0 in ID of Enemy

    Always:
    -> Start "Loop1" NObjects Enemy

    On Loop "Loop1"
    + ID of Enemy = LoopIndex of "Loop 1"
    -> Set Flag 1 of Enemy on
    -> Start "Loop2" 13 Times
    -> Set Flag 1 of Enemy off

    On "Loop2"
    + Flag 1 of enemy is on
    -> Set XPos of Enemy +1


    Hope my example helps. Again, I'm not sure what you're trying to do with your red Active object.

  • Actually what you did solved my problem perfectly. The Red active object was just suppose to be the destination the Enemies were trying to reach, "GateCheck" was just the name I gave it for my project, I forgot to change it to something more understandable for this purpose like "Destination". Thank you for your help!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!