dop2000's Recent Forum Activity

  • Then you need a function.

    Create a function SpawnNewMolecule, move all that code into the function. When a molecule becomes attached - call the function. Every 5 seconds - also call the function.

    But if you need to wait 5 seconds after each attached molecule, then I suggest you use Timer behavior on one of the objects (with a single instance). You can add an invisible sprite just to host the timer.

    On start of layout
     : Start recurring Timer "spawn" for 5s
    
    When molecule becomes attached
     : Call SpawnNewMolecule
     : Start recurring Timer "spawn" for 5s (this will restart it from the beginning)
    
    On Timer "spawn"
     : Call SpawnNewMolecule
    
  • So when the last instance of Molek is attached, or after a certain amount of time passed, I hoped to spawn another in the designated place, all dependent on what color the last one was and where it spawned, which, due to instance variables, are supposed to be one and the same.

    Ok, then pick the last created Molek, get all the important values from it (its position, color etc.) and save them in local variables. Then create a new Molek instance.

    This is just a mockup, I don't know how exactly you want to calculate the position for a new instance:

  • I know I sound like a broken record, repeating this in every post, but you should never use "Trigger once" condition with objects that have multiple instances! And don't use it in loops.

    If there is no parent event for the events on your screenshot, then the second line runs on every tick, changing the value of newColor variable 60+ times per second. So the color will be unpredictable when it's time to spawn a new molecule.

    Also, using "Pick last created" inside of "For each" loop doesn't make sense. And "Every tick" inside of "Every 5 seconds" is meaningless too.

    Basically, the way you organize events is wrong. The whole thing should be done in a single event or function.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes. And the filter with either of those tags works.

  • Are you using any addons? Could be due to a different version of one of the addons. Compare addon versions, or try saving the project with bundled addons (in project properties).

  • "tag1 tag2" works for me.

  • I'm not sure about spritefont performance, memory consumption and optimization with it. When I used spritefont before, it could constantly shift position, could be displayed incorrectly

    It's actually the other way around! Spritefont is much faster than text objects, uses less memory, and is always displayed accurately and consistently on all platforms. Webfonts, even when added to the project, are rendered differently on different devices, may shift up and down, may look fuzzy etc.

  • Create an instance variable on the Ally sprite. Then use "Ally Set value" action.

  • See my previous comment, I edited it

  • Not sure I understand your question.

    The parent "On Timer" event will trigger for an Ally instance and will pick it.

    Then the nested "Ally has LineOfSight to Enemy" condition will pick all enemies in the range. And then you find the nearest enemy instance among those that are in range.

    I forgot that On Timer can sometimes trigger for multiple instances, so it's better to add For Each loop:

    Ally On Timer "find_new_target"
    System For Each Ally
    
     Ally has LineOfSightClose to Enemy
     Enemy pick nearest to Ally
     ----> Ally set enemyUID to Enemy.UID
     ----> Ally set state to "attack"
    
     Else
     Ally has LineOfSightFar to Enemy
     Enemy pick nearest to Ally
     ----> Ally find path to Enemy
     ----> Ally set state to "chase"
    

    You can save the selected target UID in the enemyUID instance, in case you need to pick the same enemy in other events, for example to fire a bullet at it.

  • Use Timer and LineOfSight behaviors. You can have multiple LineOfSight behaviors with different settings - for example one for long range, where the unit needs to move to the target, and another for close range where it can start shooting at the target.

    Use instance variables for states. And NEVER use "Trigger once" condition in state machine code!

    Here is a very simplified example, just to demonstrate the idea:

    On Start of layout
     ----> Ally Start recurring Timer "find_new_target" every 2 seconds
    
    
    Ally On Timer "find_new_target"
    
     Ally has LineOfSightClose to Enemy
     Enemy pick nearest to Ally
     ----> Ally set enemyUID to Enemy.UID
     ----> Ally set state to "attack" 
    
     Else
     Ally has LineOfSightFar to Enemy
     Enemy pick nearest to Ally
     ----> Ally find path to Enemy
     ----> Ally set state to "chase" 
    
dop2000's avatar

dop2000

Member since 26 May, 2016

Twitter
dop2000 has 269 followers

Connect with dop2000

Trophy Case

  • 9-Year Club
  • Entrepreneur Sold something in the asset store
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Forum Wizard Made 5,000 posts in the forums
  • Forum Unicorn Made 10,000 posts in the forums
  • x5
    Popular Game One of your games has over 1,000 players
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • Enduring Visitor Visited Construct.net 90 days in a row
  • Unrelenting Visitor Visited Construct.net 180 days in a row
  • Continuous Visitor Visited Construct.net 365 days in a row
  • RTFM Read the fabulous manual
  • x3
    Quick Draw First 5 people to up-vote a new Construct 3 release
  • x14
    Great Comment One of your comments gets 3 upvotes
  • Delicious Comment One of your comments gets 10 upvotes
  • Email Verified

Progress

29/44
How to earn trophies