• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

instance_nearest

  1. B

    SOLVED Copying Variable from Nearest Instance

    I am having one moving object called objForce spawn instances of another called objPath in intervals as to make a dotted path. There are several objForce instances and they all have different colors, randomly assigned, labeled col. (visualized) I am trying to make the created instances of...
  2. lyfe264_

    GML Instance_nearest not showing the closest object

    Hello, I have an issue with the function instance_nearest(). I have two objects child : "obj_House" and "obj_Fence" linked to their parent "ParentDeco". When I collide with the object "obj_Fence" it says that the nearest instance is "obj_Fence" but if I try to then collide with "obj_House" it...
  3. J

    SOLVED Finding [nth_nearest] code NOT WORKING [SOLVED]

    I have a game where the player can pick up weapons. I want the player to be able to swap the weapon they're holding with another weapon on the floor. My code is structured so nearestweapon = instance_nearest(x,y,weaponparent). All the weapons share the same parent (weaponparent), so I run into...
  4. B

    SOLVED Multiple audio listener point

    Hi guys, I tried a very basic sound distance effect. For example, when obj_character moves away from the object_gun that has a gun_sound, sound comes to as low volume. Also moves away more, sound doesn't come. Okay that is working like this. obj_gun (Step Event) if...
  5. Kantarell

    GameMaker [Help] Changing a variable for the closest object

    Hello dear gamemakers, im in a bit of a pickle. Im working on a platformer where you can pick up melon seeds (They're basically the games coins). I want this mechanic where you can pick up special seeds, the yellow ones which are worth more, then the closest "Normal" seed becommes a yellow one...
  6. G

    Instance_nearest and Variables

    I'm making an Insaniquarium Spiritual successor in game maker studio 2 and I'm looking to have the Piranha seek out the nearest fish with a size equal to 1. it works fine until any of the fish no longer have a size of 1. if (instance_exists(Fish) && (Fish.size = 1) ){ Target =...
  7. M

    Nearest Instance in Player Input Direction

    Howdy. I'm attempting to find the nearest instance of a spring object—from the current spring object that the player object is colliding with—in the direction of the player's input, and then move in that direction. I have statements to handle different player states (the code for the ascending...
  8. H

    GML instance_nearest not working properly

    Hi all, I want my player to detect the nearest obj_planet and then run some code, but when I put in more than one of the object in the game room, one of the objects stops working and the other one works with 2x the strength of it's intended values. Here's my script: //Gravity grav_eff =...
  9. Z

    GML instance_nearest not working

    I need the guide point for the pedestrians in my GTA 2 styled game to find the nearest direction object so they can start the loop of walking along sidewalks. Long story short, I want them to get the nearest ped direction object, using a variable called resetPoint. This is the code I used...
  10. PlayerOne

    GameMaker Door warp using instance_nearest() [SOLVED]

    Trying to add the ability to "travel" within the room. I have 2 doors - DoorA and DoorB - and that when the player presses E the player will warp to DoorA from DoorB and vise versa. Problem is DoorA isn't working properly despite the fact it uses the exact code as in DoorB. However DoorB works...
  11. S

    GameMaker (Solved) problem with my instance_nearest_wrap

    can someone tell me why dist 1 and 2 are printing out as the same value? it doesn't even set my new target. the function just seems to find the first nearest and disregards the 8 other offsets Edit: oh and it finding itself is not a problem since it is printing values above 1,1 ///...
  12. B

    Change variable for all instances one at a time using proximity

    Hello, I'm trying to change a variable from false to true for all instances of an object. However, I need the values to change one at a time according to which is the closest to the player object. So, the nearest object changes, then the second-nearest, then the third-nearest, etc, all in one...
  13. B

    Legacy GM RTS Peasant Harvesting Lumber(Instance_deactivate / Instance_nearest)

    I'm making an RTS game. I'm working on the peasants harvesting lumber right now. So let's say you have the peasant selected and you tell him to harvest a tree that he can't make a path to, then he'll need to find a closer tree in that vicinity that he can make a path to. That's what I'm trying...
  14. M

    Door closing slowly[solved...]

    I made a trigger that if you touch it, the closest door is supposed close slowly, (but instead of that the game crashes) can someone tell me how to make a door fall down pixel by pixel until it has fall 64 pixels down?
  15. E

    Snap object to another object? [SOLVED]

    Hi, So basically the player is able to drag objects using the mouse. What I'm trying to achieve is; once the dragged object is close to another object, it snaps on top of it. I have working code for this... but the issue I'm having is when I have more than one of the objects in the same room at...
  16. 1

    Legacy GM Two bodies, two sets of arms for each, x y.

    Good Day. I'm making a big platform game due for release later this year and need to find a way to make two stick figures have their own set of arms using the same object. Eg: 2 of the objects of the same instance are armless (Legs, body, head only) Obj_Enemy_Stick Inst. 1 Inst. 2 Then the...
  17. L

    GML [SOLVED]Instance_nearest in one direction

    Hey everyone! So Instance_nearest checks for an object nearest in any direction. Anyone know of a way to bypass the "all direction's" aspect of it, or just find an object above you? I feel there's a really easy answer to this, I'm just not seeing it. Thanks in advance!
  18. ikonhero

    Windows find nearest instance of object with certain variable value

    I need an object to find the nearest instance of an object of a certain type that has a certain value stored as a variable. For instance obj_a has to find the nearest obj_b that has a variable set as: available = 1;. Is it possible to implement this as code without having to use multiple...
  19. G

    instance_nearest work on deactived objects?

    Simple question couldn't find it in search or help.
Top