• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

instance_nearest

  1. 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 =...
  2. 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...
  3. Harper

    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 =...
  4. 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...
  5. PlayerOne

    GMS 2 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...
  6. Shadowblitz16

    GMS 2 (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 ///...
  7. 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...
  8. 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...
  9. Megax60

    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?
  10. 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...
  11. 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...
  12. 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!
  13. 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...
  14. Ggbah

    instance_nearest work on deactived objects?

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