C#C
C#16mo ago
HeRoX1010!

Slope Physics not working when trying to make Sonic face movement direction

I'm working on a 3D sonic framework in Unity, and I'm starting to implement animations and player rotation. I ran into a bit of a problem where animations are all working as intended which is good, and the rotation works well on flat ground, but it messes up the slope physics completely, and when braking sonic turns at a slight angle for some reason. It should be in the video but it's kinda hard to pick out because I haven't added the braking animations yet. (turning off the rotation script makes everything work normally again so it's definitely the rotation script that's the problem). I've been trying to figure out a solution for a bit now but with no luck, so some help in figuring this out would be greatly appreciated.

Here are the relevant scripts for this:

RotationHandler (attached to capsule): https://pastecode.io/s/rv1418xi
MoveAction: https://pastecode.io/s/8092tzsm
PlayerPhysics: https://pastecode.io/s/p2qb2q81
This C# script for Unity manages the rotation of a player character based on movement input. If the player is braking, the rotation is ignored. Otherwise, it calculates the target rotation from the movement vector and smoothly applies it to the player transform, enhancing the gameplay experience.
Was this page helpful?