Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

GM8 Object collision bugs?

Hello! I am working in GM8 and have a problem with the game. I tried to make everything in 64 x 64 sprites so that everything is as big, making up a "perfect" grid. The problem is that objects gets stuck in the corner. That's why I did the object masks smaller. But then they loose their grid cordinates (meaning that objects move too far and get stuck still).

Also, sometimes, the objects doesn't move all the way to the wall even if I have set "precise collision checking". These pictures may help, but maybe they don't show the spaces that the objects leave between each other so well. I hope you understand what I'm talking about. There is something I've done wrong since they stop too early or move till they're stuck in the wall objects (Brown boxes area). I am sure that you are aware of the "Bug" in Game Maker where objects get suck in each other as long as you have the "stop movement" action and the solid option on.

Please help!


PICTURES:

157lu3b.png


2zg7vdg.png


2hi4b4k.png


Well I can explain how I made it work so far:

I have 9 shape objects:

1 TRIANGLE, CIRCLE and SQUARE Object (These are the DEFAULT and when other shape object types stops, they turn into this one!)
1 TRIANGLE, CIRCLE and SQUARE IN MOVEMENT Object
1 TRIANGLE, CIRCLE, and SQUARE "OFF" Object.

When you click on any shape (THE STANDARD/DEFAULT OBJECT) Arrows appears that shows you ways you can move. You can only move over grey areas (not Brown). When you click any Arrow and the shape starts moving, the one you move Changes into "OBJECT"MOVING". Other SHAPEs are turned into "OBJECT OFF". Then an object is created that destroys all Arrow buttons (step event) whenever a shape is moving (so that only 1 shape can move at a time). When a move is finished and a shape stops (at walls, other SHAPEs) the Arrow destroying object is deleted and ALL Shapes are turned into the Default again, making it possible to move the same or Another object shape again.

I hope I did a good explanation here!

DEMO DOWNLOAD:
https://www.sendspace.com/file/wfeh7g


Thanks in advice!
 
Never used gamemaker before but the "getting stuck on collision mask grid" bug is a familiar thing to me for games.

Here's some pseudo code that will cause this stuck in corner bug (And generally other sticking bugs, including not entirely meeting the edge of the maze).
C:
<div class="c" id="{CB}" style="font-family: monospace;"><ol>Point2D moveDirection = ArrowKeysToDirectionVector(); // Read input from keyboard for moving the object

moveDirection *= deltaTime; // Distance to move is controlled by frame-rate as FPS is unlocked

 

Mask movementMask = object.<span style="color: #202020;">Mask + moveDirection;

 

<span style="color: #b1b100;">if ( AreMasksCollidingOnAxis( movementMask.<span style="color: #202020;">x, mapMask.<span style="color: #202020;">x ) == <span style="color: #000000; font-weight: bold;">false ) { // Check if y movement is valid

    <span style="color: #b1b100;">if ( AreMasksCollidingOnAxis( movementMask.<span style="color: #202020;">y, mapMask.<span style="color: #202020;">y ) == <span style="color: #000000; font-weight: bold;">false ) { // Check if x movement is valid

        object.<span style="color: #202020;">Move( moveDirection ); // Move object if X and Y do not collide

    }

}
It looks fine, but the problem is moveDirection is interpolated by the frame-rate.
In this case, the object may never touch the side of walls if the frame-rate is low as the movement is making the object potentially leap a massive distance into the wall and if it moves into a corner when the frame-rate is low but then the frame-rate increases then the object will become stuck as it jumped, say [20px,20px] to get into the corner, but you're now moving [2px,2px] to escape, however you made such a massive leap into the corner while your FPS was 59 but when your FPS is 61 the leap is not big enough to escape the corner on one of the checked axis, the movement is invalid and you cannot move.

The same thing will happen if your FPS drops and you move directly into a wall and then the FPS increases, although you'll need a bigger leap to get stuck into a straight wall than into a corner.


That is my guess as to what is happening, but as I don't use gamemaker I can't be sure, I don't even know if you have to write movement logic in gamemaker.
 
Xilef":2gezsxbc said:
Never used gamemaker before but the "getting stuck on collision mask grid" bug is a familiar thing to me for games.

Here's some pseudo code that will cause this stuck in corner bug (And generally other sticking bugs, including not entirely meeting the edge of the maze).
C:
<div class="c" id="{CB}" style="font-family: monospace;"><ol>Point2D moveDirection = ArrowKeysToDirectionVector(); // Read input from keyboard for moving the object

moveDirection *= deltaTime; // Distance to move is controlled by frame-rate as FPS is unlocked

 

Mask movementMask = object.<span style="color: #202020;">Mask + moveDirection;

 

<span style="color: #b1b100;">if ( AreMasksCollidingOnAxis( movementMask.<span style="color: #202020;">x, mapMask.<span style="color: #202020;">x ) == <span style="color: #000000; font-weight: bold;">false ) { // Check if y movement is valid

    <span style="color: #b1b100;">if ( AreMasksCollidingOnAxis( movementMask.<span style="color: #202020;">y, mapMask.<span style="color: #202020;">y ) == <span style="color: #000000; font-weight: bold;">false ) { // Check if x movement is valid

        object.<span style="color: #202020;">Move( moveDirection ); // Move object if X and Y do not collide

    }

}
It looks fine, but the problem is moveDirection is interpolated by the frame-rate.
In this case, the object may never touch the side of walls if the frame-rate is low as the movement is making the object potentially leap a massive distance into the wall and if it moves into a corner when the frame-rate is low but then the frame-rate increases then the object will become stuck as it jumped, say [20px,20px] to get into the corner, but you're now moving [2px,2px] to escape, however you made such a massive leap into the corner while your FPS was 59 but when your FPS is 61 the leap is not big enough to escape the corner on one of the checked axis, the movement is invalid and you cannot move.

The same thing will happen if your FPS drops and you move directly into a wall and then the FPS increases, although you'll need a bigger leap to get stuck into a straight wall than into a corner.


That is my guess as to what is happening, but as I don't use gamemaker I can't be sure, I don't even know if you have to write movement logic in gamemaker.


I don't really understand this, but I'll try that code after all. But where do I put it and what does it do?
 
Princess Amy":1hkdfdus said:
Is there any way to say "if object is close to grid, snap to grid"?

I don't really know, Amy:P I hope I can fix it somehow. You know some levels of Shapez can't be completed since the shapez (objects) gets stuck too "early" or doesn't move all the way to a wall since they get stuck in EVERY corner.

thanks anyway
 
9robin3":1km4y8s1 said:
I don't really understand this, but I'll try that code after all. But where do I put it and what does it do?
It's pseudo code, not real code (I don't know gamemaker), also it's code that explains a possible cause of the problem.

You might be best off uploading a copy of your game development file with the bug and having someone take a direct look at it.
 
Xilef":5r0wjct2 said:
9robin3":5r0wjct2 said:
I don't really understand this, but I'll try that code after all. But where do I put it and what does it do?
It's pseudo code, not real code (I don't know gamemaker), also it's code that explains a possible cause of the problem.

You might be best off uploading a copy of your game development file with the bug and having someone take a direct look at it.

thank you I will^^
 
Please download the game Project file and identify the "errors":

HERE IS THE PROJECT FILE:
http://www.sendspace.com/file/48sx5w

INFO:
Please click on this topic link, OR in the Picture link saying "Shapez" in order to learn how to play the game.

SHAPEZ TOPIC:
http://www.arpgmaker.com/threads/78234

When clicking on a shape, 4 Arrows appear showing you the possible directions to move the objects. Arrows are destroyed against a wall.

When clicking a direction THAT chosen shape turns into object: "[shape] command" and begins to move in the chosen directrion, and other SHAPEs are turned into "[shape] OFF". Then a timeline starts on controller object (the one that Controls the rules, lives, parameters etc).
This timeline creates a object called "waiter". This object will destroy all Arrow objects as long as a shape is moving (so that no shape can move simultaniously as the moving shape). The timeline is stopped and the "waiter" object is destroyed every time shape(s) hit other SHAPEs or a wall object (the Brown boxes). When this happens all "[shape] command" and all "[shape] OFF" objects are changed back into its original object ("[shape]"). Only original "[shape]" objects can be clicked on and moved with the Arrows. Other objects CAN NEVER create Arrows this way.

I hope you now understand how I made the game logics.

Thank you very much for helping me!
 
Do you still need assistance with this? The demo you linked to is no longer available and it's difficult to see what's going on without either that or screenshots of the event pages. The only suggestion I can give with the information you've provided is to try using the "Align to Grid" function under the Move tab after the movement is finished (there's a check in the Control tab for Align to Grid, as well).
 
I downloaded the demo and I'll take a look at it when I have blocks of free time. It's going to take me some time to troubleshoot because I'm still familiarizing myself with Game Maker, but hopefully I'll find a solution fairly quickly. :)
 
Ok alright. Well I can explain how I made it work so far:

I have 9 shape objects:

1 TRIANGLE, CIRCLE and SQUARE Object (These are the DEFAULT and when other shape object types stops, they turn into this one!)
1 TRIANGLE, CIRCLE and SQUARE IN MOVEMENT Object
1 TRIANGLE, CIRCLE, and SQUARE "OFF" Object.

When you click on any shape (THE STANDARD/DEFAULT OBJECT) Arrows appear that shows you ways you can move that shape object. You can only move over grey areas (not Brown). When you click any Arrow and the shape starts moving, the one object you move Changes into "OBJECT MOVING". Other SHAPEs are turned into "OBJECT OFF". Then an object is created that destroys all Arrow buttons (step event) whenever a shape is moving (so that only 1 shape can move at a time). When a move is finished and a shape stops (at walls, other SHAPEs) the Arrow destroying object is deleted and ALL Shapes are turned into the Default again, making it possible to move the same or Another object shape again.

I hope I did a good explanation here!
 
After a little poking around, I found a solution and it's much simpler than I thought it was going to be. xD

shapezhelp_zps87cb9350.png


That's all you need to add. A collision event with the wall object that snaps the object to a 16x16 grid (the command is in the Jump section of the Move tab there). :) You should add that to the events of collision with other objects, as well. From my quick tests, that seems to fix the problem.

As a side note and suggestion, you could use variables inside the shape objects instead of having three different objects for each shape. It would involve some conditional branches in most events, but it would clean up the coding a lot. It's not a big issue now, but if you start adding more to the game, having the extra objects will make troubleshooting harder.
 
Stardust":1y90pz0d said:
After a little poking around, I found a solution and it's much simpler than I thought it was going to be. xD

shapezhelp_zps87cb9350.png


That's all you need to add. A collision event with the wall object that snaps the object to a 16x16 grid (the command is in the Jump section of the Move tab there). :) You should add that to the events of collision with other objects, as well. From my quick tests, that seems to fix the problem.

As a side note and suggestion, you could use variables inside the shape objects instead of having three different objects for each shape. It would involve some conditional branches in most events, but it would clean up the coding a lot. It's not a big issue now, but if you start adding more to the game, having the extra objects will make troubleshooting harder.


Thanks a lot man (but I use 32 x 32 grids!) I will try this out and later change every shape into 1 each. But how do I do this using variables? Right now I don't use any coding at all.

Thanks in advice!
 
I'm not entirely sure how the grid command works - 16 x 16 was the one I found to be successful. I don't know how 32 x 32 would work because I didn't try it, but 64 x 64 created some interesting results. xD

In the control tab of events, there are various options for variables. They work the same way they do in RPG Maker with 2 exceptions:

1. You MUST define them at the beginning and set them to 0 (or what their default value would be) before using conditional branches.
2. You give variables their names as you're using them (vs. working from a list). Make sure you have unique names for your variables separate from your objects and sprites! Otherwise it might mess up conditional branches.

If you use conditional branches (Test Variable), you could combine them into one object each fairly easily.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top