User Tag List

Results 1 to 2 of 2

Thread: Random Number Generator AI

  1. #1


    Join Date
    May 2020
    Posts
    1
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Random Number Generator AI

    So here is the layout

    Every second Random 5 * In counter *
    If counter = 1,2,3,4
    Then left, right ,up ,down.

    But here is the problem! If i have 2 of those ai that move around then they will both do the same thing.
    So if anyone can tell me how to use the same code to affect them all. Well that would be quite nice.

    Yes i have thought in my head that i could just make multiple counters for each AI..... Butttt..... If i have more than i dont know 10, 20. God! 30!
    Well then that would just be tedious.

    Thanks in advance!

  2. #2
    Clickteam Clickteam
    Simon's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    2,726
    Mentioned
    64 Post(s)
    Tagged
    3 Thread(s)
    Hi @Maso25 one of the most important concepts to grasp in Fusion is Object Selection. This means controlling which objects Fusion should act with/upon. If you simply say "if counter = x/y/z then make object do ..." Fusion has no way to know which object to act on and so all of them will be selected and made to do the same thing. In addition here, you're using the value of a single counter.

    Click image for larger version. 

Name:	temp.jpg 
Views:	7 
Size:	57.3 KB 
ID:	28833
    In this simple example, Fusion sets an Alterable Value ("A" in this case) of the active object to a random number from 1 to 10, every 25/100ths of a second. (red arrow)
    In event 2, it tests to see if the value is greater than or equal to 1 and lower than or equal to 4 (green arrow). If that is true, then it adds 1 pixel to the x position of the object (blue arrow). If you recreate this and run it, you'll see that the objects move independently of each other, no matter how many you create.

    The reason that this works is because we've given every object its own random number in the alterable value. In event 2 when we test this value, it allows Fusion to narrow down the objects which should be acted on based on a property which is unique to each of them, the random number. If we had tested the counter then they would all have moved, or none would move because the value was global to all of them and didn't narrow down which object should be doing what.

    I hope that makes sense

Similar Threads

  1. Random Unique number/text Generator
    By Perry in forum Guides, Tutorials, Examples, Widgets
    Replies: 3
    Last Post: 10th October 2014, 04:43 AM
  2. A Random Number Generator from a Pool
    By robsterdobster in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 19th February 2012, 09:13 PM
  3. Random Number generator
    By RoachLIVEinLA in forum The Games Factory 2 - Technical Support
    Replies: 5
    Last Post: 22nd July 2009, 02:16 PM
  4. Random Number Generator
    By bkfitww in forum Multimedia Fusion 2 - Technical Support
    Replies: 12
    Last Post: 9th December 2006, 11:30 PM
  5. Possible bug with random number generator
    By MJK in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 15th November 2006, 06:27 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
  •