Tilemap collision checking


Hello from Italy;

I have been going crazy for the last weeks and I hope that anybody will be able to help me.

I am having collision problems that have arisen both when I was checking collisions on objects or now that I am checking collisions on tilemaps.
Basically it seems that if I move in a direction without stopping the collision checking does not happen, but if I stop where a collision exists then I am not able to move forward anymore.
I don't understand what this could be.

Has anybody had this problem before? I am looking for hints or suggestions on what to look for.

Thanks, Pietro.


This is the code that I use in the step event of the main character object to check is I have a collsion:

var layer_id = layer_get_id ("layer_collisioni");
var map_id = layer_tilemap_get_id (layer_id);

if (keyboard_check(vk_right) or keyboard_check (vk_numpad6)) {
if ((tilemap_get_at_pixel(map_id, bbox_right + collisione, bbox_top) == 0) and (tilemap_get_at_pixel(map_id, bbox_right + collisione, bbox_bottom) == 0)) {
image_speed = 1;
direction = direzioni.destra;
speed = velocita;
} else if ....

I will put the sprite info in a different post.

Thanks, Pietro.


šŸ§ *penguin noises*
GMC Elder
This variable isn't set in the code you posted. If it's not actually set in that event, you're using old outdated data for the collision checking which could explain why it's acting so weird.


My fault...
collisione is set to 12 in the variable definitions.

Can you please explain a little more on "you're using old outdated data for the collision checking"?
What should I be using?


Here is the sprite (somehow it displays very large..).
The collision box is 24x24 so it should not create a problem as my tiles are 32x32.

Schermata 2020-08-04 alle 08.46.02.png


velocita (italian for speed) is set to 5 pixel. It's the amount that the character moves if the space is free.
collisione (italian for collision) is set to 12. It's the amount of pixel that it is checked to see it is free. To avoid getting stuck I check for a higher amount of pixel even though I move for lower amount.


And where are you setting speed to 0? because your code is letting you move if there's no collision in front, but that's not the code to stop you if there is a collision in front.


Ouch... You are right...
Where do you reccomend I set speed to 0?
In an ELSE at the end of the IF statements?


TheouAegis.. Please disregard my latest message.
I think I got it all covered now and I thank you for your help.
You really saved me.

Ciao, Pietro.