User Tag List

Results 1 to 4 of 4

Thread: How would one select a random enemy and run to it? (STF 2.5)

  1. #1
    Clicker Fusion 2.5
    AM_Games's Avatar
    Join Date
    Oct 2017
    Location
    40 miles west of Chicago, IL.
    Posts
    71
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    How would one select a random enemy and run to it? (STF 2.5)

    I'm trying to get my player to select 1 random enemy in a zone, run to it and stop.
    I can pick a random enemy but my player just runs towards the middle of the zone...and keeps going.
    I'm all ears.

    I made a fun little picture.



    I'm sorry I posted this same question in the wrong forum yesterday.
    Images attachées Images attachées

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,366
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    There can be many solutions to this. Assuming your game is as dynamic as possible, I'd give each enemy a value that tells which zone they are in. When needed, I'd run through all the enemies in the current zone and populate an array, list or string with the enemie's fixed id's. Then I'd select a random fixed id using Random(number of enemies in the array), and store that as the Target enemy. Now I could tell the player object to run to that object and stop when it collides with it. Perhaps I would use an invisible object to help with this.

  3. #3
    Clicker Fusion 2.5
    AM_Games's Avatar
    Join Date
    Oct 2017
    Location
    40 miles west of Chicago, IL.
    Posts
    71
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Popcorn View Post
    There can be many solutions to this. Assuming your game is as dynamic as possible, I'd give each enemy a value that tells which zone they are in. When needed, I'd run through all the enemies in the current zone and populate an array, list or string with the enemie's fixed id's. Then I'd select a random fixed id using Random(number of enemies in the array), and store that as the Target enemy. Now I could tell the player object to run to that object and stop when it collides with it. Perhaps I would use an invisible object to help with this.
    Ok ok...gotcha. What if there are like 30 of the same enemy? Does that matter? I took the Active Object and Duplicated it to make a bunch of the same enemy.

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,366
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    No problem. That's what I assumed you were doing. When I said 'run through all the enemies in the current zone', I meant running a for EachLoop on the Enemy object that has Zone equal current zone. If you have more than one type of enemy, you could have them in a qualifier and run the ForEach loop on that. If you don't know about ForEach loops and fastloops, I really recommend you go through some tutorials on it and learn them well.

Similar Threads

  1. How would one select a random enemy and run to it?
    By AM_Games in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 29th July 2019, 02:37 PM
  2. Select a random number but never the same.
    By Naturium in forum Android Export Module 2.5
    Replies: 3
    Last Post: 29th September 2018, 04:10 AM
  3. Data Elements>Sounds can I use an expression to select random one?
    By steakor in forum Android Export Module 2.5
    Replies: 0
    Last Post: 20th May 2017, 12:02 PM
  4. Select 1 of 2 flags at random
    By Thomas in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 9th June 2011, 12:41 PM
  5. How do I select a random frame in my project?
    By vbsd94 in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 13th January 2011, 05:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •