SOLVED Problem with tile collisions and tilemap_get_at_pixel

Ham

Member
I've been using all types of tile collision scripts. But no matter what code I use, I get the same error.

___________________________________________
############################################################################################
ERROR in
action number 1
of Step Event0
for object oPlayer:

tilemap_get_at_pixel argument 1 incorrect type (string) expecting a Number (YYGI32)
at gml_Script_PlayerCollision (line 115) - if(tilemap_get_at_pixel(tile_map_id, x + velocity[0], y))
############################################################################################
gml_Script_PlayerCollision (line 115)
gml_Object_oPlayer_Step_0 (line 42) - PlayerCollision();

it seems to be a problem with tilemap_get_at_pixel(), but I can't figure out what. If it helps, this is the collision code I'm currently using
1606478789102.png
 

Nidoking

Member
It says that you set tile_map_id to a string instead of a number. You either need to set it to a number or use a function to get the id from the string.
 

Ham

Member
It says that you set tile_map_id to a string instead of a number. You either need to set it to a number or use a function to get the id from the string.
yup, turns out after combing through the code for hours, I had missed one crucial thing. At the create event, I set the tile_map_id variable to be "Collidables" which is the name of my tile layer. Problem with that is I only gave it the string "Collidables". After replacing it with layer_tilemap_get_id, the thing works beautifully now. Thanks so much
 
Top