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

Collision mask not tracking on sprite??

K

Karam Al-Kofahi

Guest
At certain points in my game, the collision mask can move a pixel or two in either left or right when the sprite is not moving. This doesn't make any sense to me and I don't know why this is happening.

I am using GM1.4, and the player can move the character left and right with "A" and "D", and it adjusts their hspeed to be either -2, 2, or 0 if neither are pressed. I have a boat object which moves the character to align with it's speed, and the player can freely move around while on the boat. For example, if the boat has an hspeed of 20, pressing "A" will make the player's hspeed 18, and if "D" is pressed, then the player's hspeed would be 22. I did this by using a collision event in the boat's code to write the following:

obj_player.x += hspeed

this works perfectly, and the player can freely move around at ease, but after making the player's collision mask visible, I noticed that it bounced left and right whenever the player was touching the moving boat. This makes collision's with walls and other sorts of objects not work properly, and I haven't been able to find a solution. here is a video depicting the issue

https://imgur.com/4jbKPxG

the black box is the collision mask for the player, and the black box attached to the left end of the boat is the boat's wall essentially. I didn't show it in the video but the player gets stuck in the wall whenever he gets too close while the boat is moving. I am certain this is because of the glitching collision mask. If anyone knows a solution, I would love to hear it. Thanks guys
 

Kahrabaa

Member
Im not sure whats going on but
obj_player.x += hspeed
Try putting that in the end step event.
Whenever this thing happens to me it has with the order of wich things are moved around during each frame.

Its weird that the mask jiggles and not the sprite itself. Are you drawing the mask through the boats or another objects draw event?
 
Last edited:

TheouAegis

Member
Are your player's coordinates integers. Put in the GUI event draw_text(0,0,x) and make sure there is absolutely no decimal point being drawn. Even if it says something like "128.00" that's not an integer coordinate.

Also make sure your camera is moving at integer values. If the player is at integer coordinates but the camera isn't, that can cause stuttering of graphics sometimes. GM is very finnicky.

Has the player been scaled up at all either using the room editor or image_xscale and image_yscale?
 
Top