ID:2106415
 
Code:


Problem description:
I'm trying to implement an edge-sliding system using the pixel position of the center of mobs/tiles (getting the center of the dense tile in the direction the player is facing and the center of the mob itself, then calculating the difference between the pixel position of the two atoms relative to the world. If it's higher or lower by a certain point, slide in a certain direction by step_size until the mob can freely move in the original direction).

I've gotten this to work to the point where the sliding itself works fine when the step_size variable is a factor of 32 (32x32 tile world); however, when the step_size variable is not a factor of 32, the mob ends up moving past the point where it can pass between two tiles, and the sliding action ends up being called repeatedly.

Example:

http://i.imgur.com/R6IDMoi.png

I've tried adjusting the step_size during the sliding portion, but that just
makes the movement really wonky going from fast to slow (or slow to fast)
when the mob tries to slide through an edge.

What could be an optimal way to resolve this issue?

You may find some insight in Ter13's Edge Slide Demo.
In response to FKI
FKI wrote:
You may find some insight in Ter13's Edge Slide Demo.

Similar thing seems to happen in his demo when the step size is not a factor of 32 (or above a certain threshold) so that the character moves past the area where it can move through the blocks:

https://gyazo.com/024d71556d01d1b9f81641a363e84b48
whats your step size set to?
In response to Zagros5000
Zagros5000 wrote:
whats your step size set to?

I've tried from 1-6 (above is 3)

1,2,4 work while 3,5,6 don't.
i actually remember running into this issue since i use this demo as well. i'm pretty sure it gets confused as to which wall the mob should be sliding off of in some cases (likely when your step size can cause you to go back and fourth and be between the two walls before you go through) but i didnt narrow it down since it wasnt much of a problem for me
I'm trying to think of a way to keep the step size flexible while keeping the sliding method to work, but I can't think of any way around this problem.
youre probably gunna have to do a check to see if it fails and when it does step at a smaller rate until it doesnt fail
In response to Zagros5000
Zagros5000 wrote:
youre probably gunna have to do a check to see if it fails and when it does step at a smaller rate until it doesnt fail

I guess this could work, but wouldn't it cause the movement to be a bit wonky? (Like the mob moving at a decent pace until it reaches a corner, then suddenly slowing down to slide, only to move fast again).
im not sure if this should always be happening tbh i rarely encounter this issue and you should only notice it when you have two objects and a narrow path between them and your step size and abs pixel coord would also have to be a certain number if not then were thinking of a different issue
In response to Zagros5000
Zagros5000 wrote:
im not sure if this should always be happening tbh i rarely encounter this issue and you should only notice it when you have two objects and a narrow path between them and your step size and abs pixel coord would also have to be a certain number if not then were thinking of a different issue

Oh, I wrote corner up there, but I meant between two dense object/tiles. My bad.

you could try messaging ter13 for an alternative solution but im not sure if there is one
I'll go ahead and send him a message to see if there's an alt way. Thanks, though :p