- Home /
CharacterController.Move uses gravity even though it shouldn't
Hey everyone, I found a little problem and I have no idea how to solve it.
I'm using a charactercontroller to move my player. I'm not using no cc.SimpleMove, but as I increase or decrease the gravity setting the character follows it only on the Y axis. Demonstration:
Vector3 genSpace = transform.TransformDirection(new Vector3(generalVelocity.x, 0, generalVelocity.z) * Time.deltaTime);
//Vector3 genSpace = transform.TransformDirection(new Vector3(generalVelocity.x, 0, generalVelocity.z) * Time.deltaTime);
genSpace += Vector3.zero * Time.deltaTime;
playerController.Move(genSpace);
this has been added on the Update() method and is the only way the character moves. As you can see I'm not even modifying anything related to the Y axis and I'm in no way using gravity in the rest of the scripts.
Actually, if I remove the playerController.Move function in the script, gravity acts anyway so it has nothing to do with it. The only way to "disable" gravity for this player is straight up disabling the character controller. How should I solve this? Supposedly, the only way the charactercontroller can move is by using Move or SimpleMove.
I tried your script by setting generalVelocity.x and generalVelocity.z to random values and it works as you want it, do you have a rigidbody or something else that might affect the y position ?
Do you use a rigidbody with the charactercontroller? Have you tried removing the charactercontroller and adding it again?
Answer by FRESHDRW · Dec 09, 2019 at 12:42 PM
I've tried to add a new object with a charactercontroller and it seemed to work fine. I realized what it was. The animator was dragging my player down, don't know how or why. Thank you!