User Tag List

Results 1 to 3 of 3

Thread: 'Compare to one of the alterable values' VS 'Compare two general values'

  1. #1
    Clicker Multimedia Fusion 2 DeveloperiOS 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)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    'Compare to one of the alterable values' VS 'Compare two general values'

    Say i have 10 instances of ObjectA, does it matter which one i use ( topic )? Will both methods select instances seperatly?

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Only conditions which come from the object in question will select objects, with a few exceptions. Compare two general values will never modify the selection. Events such as collisions will select both objects. All objects involved in the condition are selected at the same time, and actions performed on those objects are run on a per-object basis. Does this help?
    Working as fast as I can on Fusion 3

  3. #3
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Yes, it very definitely DOES matter which you use!
    You almost never want to use "Compare two general values" when working with multiple instances.

    Suppose we want to have lots of Enemy objects, which will shoot at the Player when they are within 100 pixels.

    + Compare two general values: Sqr(((X("Enemy") - X("Player")) pow 2) + ((Y("Enemy") - Y("Player")) pow 2)) < 100
    -> Enemy: Shoot at Player

    This will NOT work. What will happen is that MMF2 will calculate the distance between the Player and the newest Enemy instance - and if it's less than 100 pixels, it will make ALL enemies shoot at the Player.


    + Always
    -> Enemy: Set Distance to: Sqr(((X("Enemy") - X("Player")) pow 2) + ((Y("Enemy") - Y("Player")) pow 2))

    + Enemy: Distance < 100
    -> Enemy: Shoot at Player

    This WILL work. It calculates the distance for each individual Enemy, and then compares them separately to 100.
    9 times out of 10, when people resort to spread values & fastloops or ForEach loops, there's no need - they could have just used an extra alterable value instead.

    Read these:
    http://www.create-games.com/article.asp?id=1975
    http://www.create-games.com/article.asp?id=2248

Similar Threads

  1. Compare two general values = 0 not work
    By ASD in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 31st August 2013, 04:16 AM
  2. For each and compare two general values
    By Popcorn in forum Multimedia Fusion 2 - Technical Support
    Replies: 13
    Last Post: 29th April 2010, 05:03 AM
  3. 'Compare General Values' with OINC
    By Asholay in forum Lacewing
    Replies: 3
    Last Post: 29th January 2009, 10:30 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
  •