User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Is it possible to select the nearest active object?

  1. #1
    No Products Registered

    Join Date
    Jan 2016
    Location
    Adelaide
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is it possible to select the nearest active object?

    First of all I am aware of an extension along the lines of advanced direction object. However, for two reasons this is not a path I want to take.

    1. I have already fully coded some of the objects I wish to use this function for, as active objects. To change them would mean having to completely code them again from the ground up.
    2. People told me that I needed to download advanced movement extensions to make accurate collisions but I was able to code them myself with a bit of time. The latter was far more rewarding and my last game truly felt like something I created because of it.

    So, the question remains: How do you create a system to select the nearest object of a type to the active object you want to identify?

    To be more specific, here's an example of what I'm trying to do.

    An enemy is disarmed, and it's looking to pick up a weapon on the ground. There are two swords: Sword A and Sword B — Both are an instance of the same thing. One is farther away, one is closer.
    What would you do to make the enemy's AI recognize the closer weapon as the most viable option, such that in the same scenario should Sword A be closer than Sword B, the enemy would go for Sword A; and vice versa, with potentially many more swords.

    If this is complicated, I'm willing to learn. I'd rather understand what I'm doing than wing it off of other people's creations, with no disrespect to their skill or talent.

  2. #2
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Sumo's Avatar
    Join Date
    Jul 2008
    Posts
    642
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Is it possible to select the nearest active object?

    Personally I would group all items in a qualifier and have an alterable value "distance" which could represent the distance from the AI to the item. I would then have an AI state which would call upon checking distance values for objects within a set range of itself (so it doesn't have to check all of the items, say 500 pixel radius). I would use the distance formula to compute the distance between two objects. I would probably use fast loops to compute these numbers when called for so its not running all the time. Ideally it would compute maybe 2 or 3 distances for items nearby and it would then have options on which item to go to, just in case all the items are of differing qualities. This also brings into the problem of path finding if there are obstacles in the way between the AI and the items.

    That's my first thought process. I feel like there's an easier way of just finding the closest item if that's what you want. I think there was a thread on here recently that asked a similar question about finding the closest object. You should check out how they solved that. Good luck!

  3. #3
    No Products Registered

    Join Date
    Jan 2016
    Location
    Adelaide
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would you "get the AI state to check for objects within a set range of itself"?

  4. #4
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Sumo's Avatar
    Join Date
    Jul 2008
    Posts
    642
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Is it possible to select the nearest active object?

    On second thought, I wonder if you use the distance formula with the qualifier's X and Y position, if it would only select the items that meet the condition.

    For example if you use a "compare two general values" condition and compare the distance formula using the qualifier coordinates which is less than 500 pixels, maybe it would include only those objects. Object selection in Fusion can be a pain sometimes, but if we can simplify it that would be for the best.

  5. #5
    No Products Registered

    Join Date
    Jan 2016
    Location
    Adelaide
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jeez, it's very discouraging. With any other engine it's just a matter of adding numbers together and calculating the lowest of the two. It seems that you're very limited to the actual objects themselves, and Fusion decides what you can and cannot calculate. It's all relatively limited to "Is [value] greater/equal/lower than [value]" without making dozens of events. -___- I don't want to give up on this project but if that's the way it is then I cannot complete my idea. I don't know how to approach it. I'm stumped.

  6. #6
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Sumo's Avatar
    Join Date
    Jul 2008
    Posts
    642
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Did you take a look at this thread? It poses a similar question of finding the nearest object.

    http://community.clickteam.com/threads/95700-Auto-Targeting-An-Enemy-From-Above

  7. #7
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    643
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    http://www.xable.us/closest-neighbors.php

    Get into the habit of downloading and deconstructing .mfas. It's one of the best ways to learn if you really apply yourself to understand what is going on.

    useful example/tutorial sites that might help with future problems:

    http://www.diybandits.com.au/MMF/tutorials.html (make sure you look at the articles section too)
    http://www.create-games.com/article.asp?id=1898 (he has many other good downloads and some articles on his profile)
    https://onedrive.live.com/?authkey=!...E7EE094271BBDA
    http://www.xable.us/tutorials.php
    http://www.castles-of-britain.com/mmf2examples.htm

  8. #8
    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator ProUnicode Add-on

    Join Date
    Jun 2011
    Posts
    628
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I made for you an example I hope it will be useful for you

    https://www.dropbox.com/s/6nibx93ti1...tance.mfa?dl=0

  9. #9
    No Products Registered

    Join Date
    Jan 2016
    Location
    Adelaide
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot for taking the time to make that demonstration ColdFire. I've been thoroughly examining it before even touching it with my code and it's all starting to become a lot more bearable.

    I have a question: How does comparing the "id" of each Active NPC to the loop index affect the code? I'm not really sure what that part does, but I'd love to know!

  10. #10
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Sumo's Avatar
    Join Date
    Jul 2008
    Posts
    642
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Is it possible to select the nearest active object?

    I haven't looked at the file, but I'm assuming he's comparing the ID number to the loop index so on each loop it's checking a separate item.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Can't select (dublicated) ACTIVE
    By Nuwanda in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 29th July 2014, 07:01 PM
  2. select active to a list?
    By DJ_Wild in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 6th July 2011, 08:09 PM
  3. Going to object that is nearest?
    By Solgryn in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 19th July 2009, 08:24 PM
  4. [Request]Select Object - Select in events?
    By LB in forum Extension Development
    Replies: 1
    Last Post: 15th July 2009, 10:55 PM
  5. finding nearest object?
    By Clicktastic in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 6th February 2007, 08:52 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
  •