Angling camera when pressed against wall

Hi! I have wall jumping and wall running in my game, but I wanted to make it have more response while doing so. So my plan was when you are pressed against a wall and not touching the ground, the camera would slightly tilt left or right based on the wall you are on. The only issue is the rotations are weird and they don’t always go the right way. I want it to keep the same angle regardless of where the wall is and which way you are facing. How can I do this?

For a more simple explanation, when you are pressed against a wall on your right, it rotates your camera by 7.5 towards the left. How do I keep it just like that regardless of the camera’s rotation?

I thought of just adding the rotation to the camera’s z axis, but considering this is in the update function it rotates it too far.

So does anyone know what I can do here? I’m stumped on this and have tried so much. I even tried having a check for the add to rotation to make it only go once but it just results in the camera flipping upside down.

Hi @Cryptonaph,

Could you provide a link to the project for others to look at? It will be helpful to be able to see the behaviors your experiencing and get an idea of what you’re looking for.


Ah, sorry for such a late response, you caught me on my off-time. Anyways, I just finished making it the way I kinda want it to look, but I need help optimizing it all. (Heck, this whole script needs to be optimized…)

The reason I say “kinda” is because unfortunately when you turn your camera it makes weird camera angles.

I’m currently trying to make it so when pressed against the wall and “wall sliding”, it makes you not fall as fast as normal so you can wall run. I’ll link my project here.