Spherical forums

Sphere Development => Sphere Support => Map/Tileset Support => Topic started by: Eggbertx on May 07, 2017, 08:38:47 pm

Title: GetObstructingTile finding obstruction where it shouldn't
Post by: Eggbertx on May 07, 2017, 08:38:47 pm
If I have a person (16x16 px) in a map (16x16 px tiles) touching but not overlapping a wall, GetObstructingTile returns > -1 when it seems like it should be returning -1. Is there a better way to detect if the person would actually be able to move to the given coordinates regardless whether it's touching something or not?
In the attached picture, the person spawns at 1,1 and GetObstructingTile("personName",1*GetTileWidth(),1*GetTileHeight()) returns index 0 (the wall's tile index number)
Title: Re: GetObstructingTile finding obstruction where it shouldn't
Post by: Fat Cerberus on May 07, 2017, 11:29:21 pm
That's actually correct and not a bug.

The question GetObstructingTile() asks the engine is actually not about whether the person is currently obstructed but rather, "Is it legal for the person to move here?"  For person entities, the person's current X and Y refer to the center of the sprite base, not the top-left corner of the sprite.  If that person is placed at 1,1 (in tile coordinates), its sprite base is now centered on a tile boundary and intersects the wall.  So you are indeed obstructed at (1,1), but not at (1.5,1.5).
Title: Re: GetObstructingTile finding obstruction where it shouldn't
Post by: Fat Cerberus on May 09, 2017, 12:22:36 am
In case you're still confused about the above explanation: When you set the starting location in the map editor, it actually places it in the center of the tile, not the corner.  That avoids you spawning inside the wall to begin with.