how can i make my enemy face player as well as be parallel to the ground with smooth rotation?

Hello, im trying to make my enemy ai face the player and be parallel to the ground.


This is where im at right now, as for the problem, it is that when the enemy follows me downward on a slope the rotation on the x axis resets from 15 to 0 and vice versa every frame.

Some more information about the code is that the “enemyeye” is a empty game object that im using to throw a raycast downward to detect a layermask “ground”. also to find ground angle.

There is one more problem that im facing which is that the “slerp” is not working with the look rotation. Whenever i try to add slerp to the rotation it doesnt go above 0.7 where as it should be going 15.

Dont know if this is helpful but the slope that im trying to work on is a 15 degree slope.

You can just make the enemy mesh a child of the object that contains the navmesh agent. So, Navmesh agent does navmeshagent stuff, but its child, the enemy mesh rotation can be controled independently.