User Tag List

Results 1 to 9 of 9

Thread: Picking Object Closest to Other Object

  1. #1
    Clicker Multimedia Fusion 2Android Export Module
    Corlen's Avatar
    Join Date
    Mar 2007
    Location
    Your House
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Picking Object Closest to Other Object

    I know the equation for detecting the distance from two objects but is there a way I can pick only the object closest to another object? Or perhaps use the equation I just mentioned and is there somehow a way to test which object has the lowest value in that variable the distance is stored in?

  2. #2
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Picking Object Closest to Other Object

    You can use several algorithms for distance finding- naively, iterate through all objects, comparing the distance of each to the chosen object, and recording the least value. More efficiently, if you had objects sorted by X/Y, you could perform a binary search on them to cull the list of scoped objects over both X & Y, then compare only the remaining object- more robust for an application with many objects, whereas smaller scales the overhead would outweigh any efficiency saved.


    But a much easier way is to use the "Select Object", which has a function built in for "Select object with lowest value", where you can just set that value for the object to the distance.

  3. #3
    Clicker Multimedia Fusion 2Android Export Module
    Corlen's Avatar
    Join Date
    Mar 2007
    Location
    Your House
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Picking Object Closest to Other Object

    Cool it works! I couldn't use a fastloop because fastloops don't work with collision boxes built into animations, at least for me. This is probably more efficient anyway than a fastloop. Thanks again. I'm putting all you guys who helped me with these problems in the "special thanks" portion of the credits of my game.

  4. #4
    Clicker Multimedia Fusion 2Android Export Module
    Corlen's Avatar
    Join Date
    Mar 2007
    Location
    Your House
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Picking Object Closest to Other Object

    OK SOOOO I've sort of ran into a new problem. I had to have a bullet that moves instantly across the screen via fastloop create bullet testing active objects on every place it has moved in position to before it changes position. I have the gun that fires the bullets use the above to only damage enemies closest to you if you fired an uncharged shot but if you charge the shot it goes through all enemies instantly by not testing for the closest enemy to you. Now the problem is the enemy collision boxes are 14x14 and the bullets are 6x6 and I have this little bullet collision animation. It works fine for the uncharged shot where I create the blast animation on the bullet testing object, but when it goes through enemies is where things start getting messed up. The bullet testing object is small enough where three of them can collide with an enemy at once. When the charged shot hits, all three of these testing objects in question have a bullet collision animation display instead of just one and I don't know how to make it pick only one per enemy so only one animation is created. Any ideas?

  5. #5
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Picking Object Closest to Other Object

    Select Object again? Splitting your code into two events if necessary.

  6. #6
    Clicker Multimedia Fusion 2Android Export Module
    Corlen's Avatar
    Join Date
    Mar 2007
    Location
    Your House
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Picking Object Closest to Other Object

    What would I use in the select object, though?

  7. #7
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Picking Object Closest to Other Object

    Try "select first" or "select last" and see what happens.

  8. #8
    Clicker Multimedia Fusion 2Android Export Module
    Corlen's Avatar
    Join Date
    Mar 2007
    Location
    Your House
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Picking Object Closest to Other Object

    Didn't work, it only creates a single bullet collision animation even though multiple enemies are hit.

  9. #9
    Clicker Multimedia Fusion 2Android Export Module
    Corlen's Avatar
    Join Date
    Mar 2007
    Location
    Your House
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Picking Object Closest to Other Object

    I got it fixed. I just have a ForEach loop start for the object it collides with and then in the ForEach condition I pick the bullet test object closest to the player.

Similar Threads

  1. Closest object with ForEach
    By Tiles in forum File Archive
    Replies: 20
    Last Post: 26th February 2011, 01:00 PM
  2. Follow the closest object
    By CloudJDR in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 17th November 2009, 02:59 AM
  3. need help with picking an object
    By method72 in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 11th September 2009, 01:31 AM
  4. Find Closest Object?
    By Dines in forum Extension Development
    Replies: 5
    Last Post: 21st December 2006, 11:10 AM
  5. Closest Object A to Obect B
    By MechatheSlag in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 7th December 2006, 07:28 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
  •