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

GameMaker collision event not triggering

J

jonomiko

Guest
I can't find a way to get code in the collision event of an object to be read. I countered this by using instance_place to make a self made collision check and do. But, it would be easier for me if that event would be triggered properly.

Both objects have a it's proper mask. I don't use physic. One is solid, the hero, and the other is not, a warp zone. When the player get pass a certain point in a map, i want to room_goto to another map.

Anyway, all reason are good to use a collision event, since collisions are essential.
 
U

Ulrich6

Guest
Are you sure both objects have its sprites set? You can't work with collisions without sprites.

Also, if you want to switch to another room when the player gets pass a certain line in the map (like a rectangular region in the room), you don't need collisions for that. You just have to check if the x or the y-coordinates of the player are bigger/smaller than a certain value.
 
E

Ephemeral

Guest
One is solid, the hero
1) a moving instance should not be set to "solid" I think.
2) IIRC the "solid" property locks off the normal collision system, so you'll never get a collision because behind the scenes GMS2 is checking that there will be a collision, and then stopping the instance before it can happen?
 
J

jonomiko

Guest
Yes objects have correct sprites. The reason why i want to use objects to move the hero from room to room is that i dont have to write all those coords somewhere. In my game, doors, or warp zone are not all in the same screen zone. In that way, i can easily see where are my doors when i'm coding. It would work the same as checking if the x of the player cross certain values without having to record all those value manualy.

I tried to uncheck the solid box from the hero object but with no success. The code in the collision event (with the hero object) in the door object doesnt want to be run.
 
J

jonomiko

Guest
I get around it by writing this code is the step event of the door object : if place_meeting(x, y, o_hero) <code to change room> It's a simple way to get things running.

But why do i have to do this manually and the collision event doesnt work ?
 
H

Hiesetsu

Guest
I have the exact same problem. I made a simple coin object and made an collision event on my player object for when it touches the count, and it simply doesn't work. They are on the same object layer, and neither are marked as solid or using physics. I ended up using place_meeting in the step event, and that worked fine, but I can't just jam all my collision code into step events and expect things to keep running smoothly.
 
// I'm not expecting anyone here to react since the post is 7 years old but in case someone new stumbles upon the same problem //

Just had a similar problem where the collision code didn't run.
Not sure what exactlyfixed the bug, but here's how I went about it:

1.) object - > collision mask - > "same as sprite" or just manually select the same sprite that your object has.

2.) then sprites properties -> Collision mask -> Manual -> Rectangle ( or whatever you want it to be ) -> and just manually select the area of the sprite that you want collision detection for.

3.) Then under the object itself. Ticked SOLID ON and then again SOLID OFF.

4.) then I copied the entire collision event code block. deleted the collision event. And remade it again, pasted the code in.

5.) saved the project.

6.) Pressed the "Clean Project" button (shortcut: CTRL + 7)

And after all of that, I reran my game and the collision event triggered correctly.
 
Top