Skip to main content
↑
↓
Spherical forums
Community for the
Sphere game engine
New?
Contact Us
to register an account!
1 Hour
1 Day
1 Week
1 Month
Forever
Community
Help
Search
Recent Posts
Log in
Contact Us
News
Spherical
Facebook
-
Twitter
-
Discord chat
New?
Contact us
to register an account!
Sphere Development
Sphere Support
Map/Tileset Support
GetObstructingTile finding obstruction where it shouldn't
1
Print
Topic: GetObstructingTile finding obstruction where it shouldn't
(Read 4989 times)
previous topic
-
next topic
0 Members and 1 Guest are viewing this topic.
Eggbertx
High Poster
Posts: 352
Logged
GetObstructingTile finding obstruction where it shouldn't
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)
My GitHub
QtSphere IDE, (eventually) the one Sphere IDE to rule them all
Fat Cerberus
Big Chungus
Posts: 2,774
*MUNCH*
Logged
Global Moderator
Sphere Developer
Re: GetObstructingTile finding obstruction where it shouldn't
Reply #1
–
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).
neoSphere 5.9.2
-
neoSphere
engine -
Cell
compiler -
SSj
debugger
forum thread
|
on GitHub
Fat Cerberus
Big Chungus
Posts: 2,774
*MUNCH*
Logged
Global Moderator
Sphere Developer
Re: GetObstructingTile finding obstruction where it shouldn't
Reply #2
–
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.
neoSphere 5.9.2
-
neoSphere
engine -
Cell
compiler -
SSj
debugger
forum thread
|
on GitHub
1
Print
Sphere Development
Sphere Support
Map/Tileset Support
GetObstructingTile finding obstruction where it shouldn't