Jump to content


Photo

Finding Nearest Instance for Large Amounts....


  • Please log in to reply
3 replies to this topic

#1 FatalSleep

FatalSleep

    Dominus Veroth

  • GMC Member
  • 1220 posts
  • Version:GM:Studio

Posted 19 December 2011 - 12:03 AM

Okay I have a code that finds the nearest instance for around 180 different points.
I'm using codes: for() + variables + instance_nearest()

In result each step it should create a variable and that variable finds the nearest instance to the indicated point in the for() code.

Here is the code:
Spoiler

Here is the reference:
Spoiler


Now instead of it finding the nearest instance for each point, it only finds the LAST instance for the LAST point and I don't know why.

Edited by FatalSleep, 19 December 2011 - 12:07 AM.

  • 0

#2 paul23

paul23

    GMC Member

  • Global Moderators
  • 3357 posts
  • Version:GM8

Posted 19 December 2011 - 02:22 AM

- What is the "instance_nearest" code?
- What is the code around this, how is this called (What you do with li[], where you initialize x1[] & y1[]).


There 3 lines of code give little indication.
  • 0

#3 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9259 posts
  • Version:Unknown

Posted 20 December 2011 - 07:21 AM

@paul23: Um...instance_nearest(...) is built in to GM... :huh:

@FatalSleep: It looks like it should work fine. Are you sure that the instance closest to the last point isn't also the instance closest to every other point? And how are you checking it? Make sure you're checking the right array indexes for li[], which should go from li[0, 0] to li[14, 11]...

-IMP
  • 0

#4 FatalSleep

FatalSleep

    Dominus Veroth

  • GMC Member
  • 1220 posts
  • Version:GM:Studio

Posted 20 December 2011 - 07:41 AM

IMP I wanna give you a hug!!!! It creates the blocks I need at the right points, but the positions being checked for are not at the right points at all!!! They are set at 0,0.... :/
I wanna give you a hug. :)

I am pretty experienced with gml and I feel rather... noobish to forget to do such a simple thing. :)
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users