I don't remember when the "Allows Sliding" property was added to the 8-direction behavior, but I thought it was exactly what I was looking for in my project. The player could get snagged on some solids in spots and I thought it could help gracefully slide around objects at times.
It did help, but I noticed it caused a lot of shaking at times. When I held on the movement controls to keep the player moving into a solid either several objects would shake or the entire screen would shake, maybe due to scrollTo behavior on the player is shaking the viewport/camera.
I'm not wanting to file a bug report (or complain) as I seem to have found one solution: Turn on pixel rounding in the project. I'm not wanting to do this in my project as it seems to make the camera movement choppy at times.
Another solution to the shaking objects it to make sure objects are at integer pixel values themselves. I tested that and it stopped objects from shaking. This didn't stop the entire screen from shaking at times though, as I assume that is caused by the player being at a non-pixel value.
Instead of trying to troubleshoot this and add a bunch of changes (in my large project) to prevent this, I thought it might be better to re-create this functionality. I always view pre-built functionality, such as behaviors, as quicker to use but less flexibility, whereas custom solutions can take longer (sometimes much longer) to create but can be fully customized.
In this case I mainly just want players to not get stuck going through doorways as easy. At least that was the only real spot I was getting caught on. I don't have that many diagonal (non-rectangle) solids in my project so I don't need much sliding. So I don't even need to re-create the entire functionality; I just need something very specific.
Trying to think how the sliding functionality works under the hood, I figured if moving down and running into a solid, it might simply check if the object can continue to move down if moved slightly to the left or right. I thought that might be why the screen shakes - as the sliding mechanic keeps moving the objects back and forth to check for slidability.
I created a sprite that if overlapping with the player while moving the event would set the player's X value over one pixel. A bit to my surprise, it worked and looked as smooth as can be! I added some variables to the object to control direction and amount and came up with this event:
Now I'm not sure this will be my final solution. I just came up with it and I'm not excited about having to have four extra sprites in the project for each doorway. But it definitely is helping so I'm gonna roll with it for now, fine tune it as I go, but also be open to trying completely new solutions.
GIF: imgur.com/a/v0bCft1
So why am I posting this? One is just to share this in case anyone else is looking into this. But though I don't have a specific question I'm asking, I would love any additional info on any of the topics I've brought up or corrections on some of the assumptions I've made. So for example:
- Anyone else experience the shaking when allow sliding enabled? Any other solutions to resolve?
- How does allow sliding work under the hood? (I actually haven't looked if any of Construct's code/repos are public)
- Has anyone implemented their own custom sliding mechanic?