I'm working on a movement engine that I want to have some 2.5d aspects to it.
I'm trying to make it so that when you walk on an obstacle background that has a slant to it, it will act as though it is a slope. Here's a picture to (sort of) show the effect I'm trying to get...
Right now I have two sensors on either side of the player that sense where the walls are, and they calculate the slope of the wall at the same time. When the two slopes are similar it will add the average of the two slopes to the players Y position.
While this method sort of works, it's not as smooth as I would like. I've tried a number of things to make it look better but I'm still not satisfied with it. Can anybody give me some tips?
I made a 2.5D engine that used different active objects for different types of terrain (because I was too lazy to program a height map for the second time) and that used right-triangle trigonometry based on the position relative to the slope object and the height of the terrain as determined by alterable values, so that if it had a height of 64 (pixels) and length of 32 (as determined by the actual object size) with another value determining direction of going up as you move right, it would have a right triangle with base 32 and height 64, or 2 pixels of displacement per one pixel distance into the object.
Of course, that's completely different to what you're doing right now...
i'm really not experienced in doing stuff like this, but i imagine it's rough since you're snapping the sensors to raw pixel slopes; you may draw a 30º line but once it's rasterized it becomes too rough to be reliably measured as 30º, without knowing the exact endpoints. this is possible with simpler angles such as 45º or 0º though.
what would work better is if you sampled each line at multiple points and averaged their slopes... however this has a problem of "softening" corners, which becomes more pronounced the further you sample from the base sensors. plus it's still not exact. there's also the additional overhead if you need this applied to many objects
if you wanted it to be perfect you'd almost have to have straight point data for your lines stored in a separate file, or have some other way of just telling your engine "this is a 30º" without needing to measure the lines themselves, which is of course less flexible.