05-22-2014, 04:51 PM
Okay, so I have this one scene where the player can use an item from different angles in order to get a slightly different result, but I'd like to improve this detection. Right now it uses 8 areas, 4 facing each cardinal direction and 4 in between those. I named the areas with _n_, _ne_, _sw_ etc. I have a UseItem callback on all areas calling the same event, using StringContains on asEntity to detect which area it is, then execute slightly different code for the results. It all works just like I want it, but it CAN be a little inaccurate at times.
To explain a bit further what is going on, you use this item from different angles to place the item at the angle you used it from. If you use the item on the _nw_ area, the item will spawn facing the north west. The area in the middle (inactive in the pic) is used to pick up the item again after placing it, by interacting with it. The area on top is just to block the player from using it on the area on the opposite side of the column, by touching the edge of that area. It works to prevent that, but it doesn't prevent using the item on the edge of the side areas.
Basically, if you're standing on the north side, I want the item to appear facing north, but if you use the item at the very edge, you might be able to hit the west or east areas instead, and thus the item will face that direction. I don't want that.
Sooooo, to my question (finally). Is there a better way to detect the players position in relation to an object? The GetEntitiesCollide script does not support Player.
If I can't get a hold of a better way than what I have then I'll just go with it, because it works fairly well, but not perfectly.
Any suggestions are very much appreciated <3
Spoiler below!
To explain a bit further what is going on, you use this item from different angles to place the item at the angle you used it from. If you use the item on the _nw_ area, the item will spawn facing the north west. The area in the middle (inactive in the pic) is used to pick up the item again after placing it, by interacting with it. The area on top is just to block the player from using it on the area on the opposite side of the column, by touching the edge of that area. It works to prevent that, but it doesn't prevent using the item on the edge of the side areas.
Basically, if you're standing on the north side, I want the item to appear facing north, but if you use the item at the very edge, you might be able to hit the west or east areas instead, and thus the item will face that direction. I don't want that.
Sooooo, to my question (finally). Is there a better way to detect the players position in relation to an object? The GetEntitiesCollide script does not support Player.
If I can't get a hold of a better way than what I have then I'll just go with it, because it works fairly well, but not perfectly.
Any suggestions are very much appreciated <3