Unity 3d Player Rotation while walking on wall

Started by
0 comments, last by samuel74 2 years, 12 months ago

Hey Guys

I'm currently working on a 3d game where the player can walk on the wall. It works quite fine that the player walks on the wall. My only problem is the players rotation.

I'm working with cinemachine freecam so I changed the settings so the camera rotates to the wall aswell.

The issue / bug I got is that when I'm trying to rotate the player facing the same way as the camera does it works but only for a certain angle then it doesent rotates there anymore. I noticed that if I tweak the y and z rotation by putting away the minus and adding it to the other one the rotation works for the other half of the angle.

I'm using this code to rotate and also using it for when the player is on the ground.

On the sketch u can see that the player isn't able to rotate on certain angles (green) but not on the red one. the under one is what I want to achieve


transform.localEulerAngles = new Vector3(playerCam.transform.localEulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z);

This topic is closed to new replies.

Advertisement