Using Tile API - When player collide with a tile, get that tile's ID

rreaksmey

  • Posts: 15
Hello all stencylers, and expert,

I just found out about an extension in Stencyl, call Tile API. I want to use this extension to implement many things, for the moment I'm struggling with how to get a tile's ID that the player actor collide with (I don't care for left, right, top, bottom position for the moment). So, if anyone know or has worked with this before please guide me through this.

Thanks.

Hectate

  • *
  • Posts: 4643
The problem you have is that actors don't actually collide with the tiles per se, but instead they collide with a collision shape that Stencyl creates for you at the border of collide-able tiles. As a result, the game doesn't know what tile you collided with - only that you collided with a shape that corresponds to the tilemap.

You can absolutely use the Tile API for this, however. The "Collision ID For Tile At Row: (number) Col: (number) LayerID: (number)" block could be used to see what the ID is for a tile that the player collided with; if the location of the tile is known (presumably it is near the player, of course).
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

rreaksmey

  • Posts: 15
OK, I see. Let me test, and play around with that, thanks for your reply.

Epic428

  • Posts: 1118
Just to add to hectates post. Might be helpful to get what side of the player was hit at the time of collision and the get the tile a few pixels from the actor in that direction.  So ie player is hit at bottom and origin of player is center then get tile at location (player.x, player.y plus half player height plus 5 pixels). 
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

rreaksmey

  • Posts: 15
Just to add to hectates post. Might be helpful to get what side of the player was hit at the time of collision and the get the tile a few pixels from the actor in that direction.  So ie player is hit at bottom and origin of player is center then get tile at location (player.x, player.y plus half player height plus 5 pixels). 

Hi Epic428, I get your point, thanks for the explanation.
If I can get it work, or anything I will let you know.