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

Legacy GM [Collision Question] What am I doing wrong?

Hey,

Basicly, I create an object using "with(instance_create(...))" and assigning variables while creating. I'm assigning a random -not random but lets say like that- sprite to that object while it has no sprite at first and inside this object, I check the collision with a parent object using "position_meeting()" but the collision is not sprite based but 1x1 point based on mouse x/y.

So I can solve the problem with using "collision_rectangle()" but that'd take a long time depending on my current codes.

Any ideas?
 
Last edited:

TheouAegis

Member
not sure what your problem actually is, but a couple things to remember. When you create an object using instance create, all of its create event will run first, then the game will go back to the object that created it and continue running any more code you have. So your create event cannot have a place meeting check or anything that would involve it's on bounding box, because it doesn't have one yet. Any place meeting checks will have to be run after you have assigned it a Sprite. Now there are a couple things you can do to do this. The first method is to have the object that creates it call the place meeting check after it has given the created instance a new Sprite. Alternatively, you can use a global variable and have the object creating the instance first set the global variable and then create the instance, and you would have inside the create event of that object code that would set the Sprite based on the value of that global variable, and then call its place meeting code.
 
not sure what your problem actually is, but a couple things to remember. When you create an object using instance create, all of its create event will run first, then the game will go back to the object that created it and continue running any more code you have. So your create event cannot have a place meeting check or anything that would involve it's on bounding box, because it doesn't have one yet. Any place meeting checks will have to be run after you have assigned it a Sprite. Now there are a couple things you can do to do this. The first method is to have the object that creates it call the place meeting check after it has given the created instance a new Sprite. Alternatively, you can use a global variable and have the object creating the instance first set the global variable and then create the instance, and you would have inside the create event of that object code that would set the Sprite based on the value of that global variable, and then call its place meeting code.
Thanks, I did the globalization thing you said and beside that, I changed pos meeting to place meeting which was probably the whole problem but that way I fixed it cleared my code and made everything easier, thanks for your time :]
 
Top