Walk around square platform
Hi, I'm trying to make a character that walks around a platform and if the character reach a corner, it rotates and continue walking on the side of the platform, same with the bottom part.
This is a visual representation of what I'm trying to achive.
The specific problem is when the character reach the corners, the rotation just go crazy. I'm trayng to achive this using a raycast from the character to the platform and if the raycast doesn't find floor, I start the rotation like this:
times++;
transform.rotation = Quaternion.Slerp(transform.rotation,Quaternion.AngleAxis(times*-89.9f,Vector3.forward),Time.deltaTime * RotationSpeed);
_characterGravity.SetGravityAngle(transform.localEulerAngles.z);
I'm using a characterGravity script that allows me to change the gravity direction for the character in order to not fall when is walking upside down or on the sides. But this is not working propperly. Is there a better way to do this?
Your answer
Follow this Question
Related Questions
I want to stop movement of character while i call animation like Kick Jump Punch etc.. Please help 1 Answer
Object's mesh does not move/rotate when object moves/rotates 0 Answers
How to make player go forward when he is rotated? 0 Answers
Mathf.Clamp not clamping properly 0 Answers
How to adjust a GameObject's rotation to face it's moving direction ? 0 Answers