User Tag List

Results 1 to 4 of 4

Thread: Calculating distance with multiple duplicate objects - Magnet behavior

  1. #1
    Clicker 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)
    Bree's Avatar
    Join Date
    May 2014
    Posts
    313
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Calculating distance with multiple duplicate objects - Magnet behavior

    Hi all!

    Trying to work out how I can make this work properly. Going to have multiple duplicate objects created offscreen and floating upward towards the player. when the player gets close to one within 200 pixels I'd like all of the objects within that area look towards the player like a magnet. I got it sort of working, but I notice it only goes off from the last created object, so anything that floats past that was created earlier doesn't get triggered.

    How can I change the code so all duplicate objects are being checked for a distance of 200 px? Thanks for any advice!
    Attached files Attached files

  2. #2
    Clicker Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2015
    Location
    Australia
    Posts
    166
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    The "Compare two general values" doesn't scope individual objects the same way as something like collisions or comparing an object's own alterable value (so it doesn't look for objects the same way)

    If you store the distance though of each object to the player as an alterable value, then you can check the value for each object:
    magnetex2.png

    This will make the objects float towards the player if that individual object is <200 pixels away.

    This won't make the whole 'squad' of objects all nearby start floating towards the player (i.e. if some objects in the 'squad' are further than 200px then they won't move towards the player), but you could make it so any time an object starts flying towards the player it creates another (bigger and invisible) object. That's a little bit trickier to do, but here's one way of doing it that I hope makes sense:

    magnetex3.mfa (The first frame will just make nearby objects float towards the player, the second frame does the 'squad' behaviour)

  3. #3
    Clicker 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)
    Bree's Avatar
    Join Date
    May 2014
    Posts
    313
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Thanks so much marb! That's fabulous, learned a lot with your example. Much appreciated!

  4. #4
    Clicker Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2015
    Location
    Australia
    Posts
    166
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    no worries, glad I could help!

Similar Threads

  1. Replies: 2
    Last Post: 20th March 2017, 01:44 PM
  2. Replies: 1
    Last Post: 3rd July 2016, 01:13 PM
  3. Replies: 5
    Last Post: 17th May 2016, 10:09 PM
  4. Multiple duplicate objects overlapping, not individually responding to Qualifiers.
    By ratty in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 5th July 2012, 09:20 PM
  5. Calculating Distance from Player
    By Zenoff64 in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 20th January 2008, 02:18 PM

Posting Permissions

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