#How do I program a collision for a tileset?
16 messages · Page 1 of 1 (latest)
you need to collide with the tilemap rather than the tileset. The tileset is your asset in the asset browser, the tilemap is your layer in the room where you drew the tiles
so you need to do layer_tilemap_get_id to get the tilemap ID, and then plug that in
ah
move_and_collide(xsp,ysp,tile_collision)``` swap out Tiles_1 for whatever your tile layer is
ok let me try that
ok this worked. Thank you so much
ok so I got a new problem. I'm now trying to code jumping and I'm trying to program my character to recognize when its standing on said tileset. I wrote the code `if place_meeting(x,y+1,"Tiles_1")
{
ysp=0
if keyboard_check(vk_up)
{
ysp=-2
}
}
var tile_collision = layer_tilemap_get_id("Tiles_1");
move_and_collide(xsp,ysp,tile_collision)`
but it causes the game to crash upon launching it
ok so I fixed it but now I have a new problem
my character won't move at all
`ysp+=0.1
xsp=0
if keyboard_check(vk_left)
{
xsp=-1
}
if keyboard_check(vk_right)
{
xsp=+1
}
if place_meeting(x,y+1,TileSet1)
{
ysp=0
if keyboard_check(vk_z)
{
ysp=-2
}
}
var tile_collision = layer_tilemap_get_id("Tiles_1");
move_and_collide(xsp,ysp,tile_collision)`
this is my current code for my character.
I could move my character just fine before I added the "if place_meeting" lines