Skip to main content

News

Topic: GetObstructingTile finding obstruction where it shouldn't (Read 490 times) previous topic - next topic

GetObstructingTile finding obstruction where it shouldn't
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)

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
Re: GetObstructingTile finding obstruction where it shouldn't
Reply #1
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).
miniSphere 5.0.1 - Cell compiler - SSj debugger - thread | on GitHub
For the sake of our continued health I very much hope that Fat Cerberus does not become skilled enough at whatever arcane art it would require to cause computers to spawn enourmous man eating pigs ~Rhuan

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
Re: GetObstructingTile finding obstruction where it shouldn't
Reply #2
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.
miniSphere 5.0.1 - Cell compiler - SSj debugger - thread | on GitHub
For the sake of our continued health I very much hope that Fat Cerberus does not become skilled enough at whatever arcane art it would require to cause computers to spawn enourmous man eating pigs ~Rhuan