• 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!

with statement

  1. Paul Kankiewicz

    SOLVED [SOLVED] "with" Statement Fixes Movement/Collision Issue

    Hi y'all. I'm working on a multiplayer 2D platformer and ran into a weird issue that didn't make sense to me, so I thought I'd post here to see if anyone knew what's up and could tell me what might be going on. I've got a lot of AAA game dev experience, so generally when I run into an issue like...
  2. Merrick82

    SOLVED [Weird Issue]: with(parent object) running a non-child object

    So this is a wierd one. I have a draw controller objects that I use to manage the order that objects are drawn. I use three of them because there are 3 floors in my oblique top-down game. The draw controllers runs draw events for children of a parent object (par_depth), but I get an error...
  3. T

    GML Problem using "with"

    Hi! .... I apologize for the bad writing, I am a Spanish speaker and I do not speak English very well. I have a problem with a code. I try to create a code that allows me to control other objects to give instructions and behave as a "group". n_enemy_0 = instance_number(enemy_0); enemy_0 =...
  4. G

    Question - Code with(){} with scripts bug, need help(GM:S1.4)

    I have a function that lists all collisions with specified object: ///instance_place_list(object) var obj=argument0; ids = ds_list_create(); with(obj) { if(place_meeting(x,y,other.id)) ds_list_add(ids,id); } return ids; This function runs for every enemy in every step to check...
  5. T

    SOLVED using 'with' to grab child objects

    Hello all, I'm attempting to put all 'Event Cards' into one randomized list. each Event Card is a manually created object. From reading the help on 'with' statements, as well as googling around, this is what I came up with: I made an object 'oEventCardParent,' and made it the parent of all...
  6. S

    GameMaker Placing game piece in relation to game board

    I'm trying to build a board based game where you move pieces around on a board. I want the piece to be locked to a grid based on the board. In the current version of the game, it crashed as soon as it loads up. Here's the error: ___________________________________________...
  7. A

    Legacy GM with (other) not working properly

    I have an projectile and I have an enemy in the enemy's step event I try to make it so that if it touches a projectile it supposed to: -lose a point of health -destroy the instance of the projectile var hit = place_meeting (x,y,obj_player_projectile) if (hit) { enemyhealth -=1; with...
  8. A

    What exactly is the With-statement doing behind the scenes?

    Greetings GameMakers! I'm curious what exactly the with statement is doing behind the scenes. Is what is going on behind the scenes in GMS2 when we use "with(obj_pushable)" amount to looping through all instances and checking if object_index == obj_pushable? Then how does it make each instance...
  9. P

    GML SOLVED: Drawing A Surface Onto Another Surface From Another Object

    Hi all, I know it's possible to create a surface in an object and then use the with() function to draw multiple other objects onto that surface whilst it's targeted, and have managed to use this successfully. However, in an attempt to optimise my draw pipeline I was hoping I could do the...
  10. KPJ

    GameMaker With statement help (GMS2)

    Hi everyone! I need help with the "with" statement in gms2. I am making a top down game, and I want it to be so that if the player gets in the enemies field of view, the enemy's state will be "alerted". However, I also wanted all other enemies that were within clear view to be "alerted" as well...
  11. foreverisbetter

    Question - Code anyone has problems with variables in a with statement?

    I've come across a strange bug - at least it seems to be a bug - in which the x and y variables of an instance within a with statement return the values of the actual current instance - not the instance the with statement refers to. Has anyone else had the same experience? My IDE is...
  12. G

    GameMaker [Solved] - how to set new object variables using with statement

    Player creates an enemy seeking bullet that tracks down an enemy. The code to choose a target enemy is within the player object. I want to set the bullet's target (enemy id) when the bullet is created from within the player object. From within the player object, if I use something like this...
  13. kjagrpk908

    GameMaker About with() statement performance

    I hope to know with() statement performance. Whitch should I use case1 or case2? (for performance up) Case1: //---------------------------------------- oOBJ.x = oOBJ.x + 1; //--------------------------------------- Case2: //--------------------------------------- with(oOBJ) { x = x +...
  14. Y

    Shaders How to/ is it possible to temporarily apply a shader to an object through a with statement?

    So I have a cursor object and when it hovers over any object that is a child of "selectable" I want the object to have a outline around it. The way I would like to accomplish this is through a with statement located in the cursor object that applies a shader to the object it is hovering over...
  15. Le Slo

    GameMaker With statement and child objects

    Hello! I've been having troubles I don't really understand with the with statement and object parenting. Here is what I have: -An obj_laser. -An obj_laserAttack (child object of obj_laser). So, I need to save the positions of those objects, and for that I use the following to save the...
  16. N

    Legacy GM With but not self.

    Hi, this doesn't work: with (obj_projectile(not self)) instance_destroy(); Can someone please give advise?? Thank you!
  17. RyanC

    Legacy GM Question about the with() statment

    Hi Guys, I often use the with(obj_something) statement and was wondering if anyone knows what kind of performance hit there is if the obj_something does not exists in the game. for example lets say obj_enemy_1 does not exist in the game yet. would these two functions have the same performance...
  18. D

    GML "With" priority?

    Hello. I have a question regarding the with construction. When you create an object with the with construction, does the code within the with construction or the objects create event code occur first? An example would be if there was an object named objThing. This is the create event code of...
  19. T

    GML "with()" exits while loop

    Good evening. I have a while loop, supposed to generate a specified amount of objects. It runs fine unless i try to pass in a property with the with() method. If i do so, there is just one object created, and the while loop seems to be stopped. here is my code: particleAmount = 50; this runs...
  20. kraifpatrik

    Shaders Depth ordered with statement

    Hey everyone, throughout the time working with shaders in GM, I've found it convenient to set the visible property of all objects that I want to apply a shader on to false and then simply draw the objects in a single renderer object with shader_set(myShader); with (myObject) { // draw...
Top