- Home /
Charactercontroller.isGrounded never triggers
Hi, I'm just trying to implement basic jump ability on my 3D character, then realised, perhaps since beginning game, priestController.isGrounded is never triggering at all (I confirmed with print console command). Using Unity 2018.1.
This is still all in the Update() function at moment, not FixedUpdate(), but I assume that's not the issue. The movement and rotation of character all work fine, and they fall off things and fall back down to ground via gravity OK. It is standard CharacterController component, I have no rigidbody component on the character, do have Animator component on character in case relevant.
Radius of characterController is 0.7, Skin width of character controller I changed from 0.08 to 0.01, still isGrounded not triggering.
Other answers mention things about the order of the Move function related to checking .isGrounded, something about moving to not grounded state each frame, but not sure if and how this could help in my case. A thousand thanks for any suggestions.
if (!hasRotationGravityFrozen)
{
// is grounded is never triggered at all
if (priestController.isGrounded)
{
print("I'm grounded!");
gVelocity = Vector3.zero;
if (canJump && Input.GetKeyDown(KeyCode.Space))
{
gVelocity.y = 0.5f;
priestController.Move(gVelocity * Time.deltaTime);
}
}
else
{
// this is working fine
gVelocity.y += Gravity * Time.deltaTime;
priestController.Move(gVelocity * Time.deltaTime);
}
// this is working fine
if (this.transform.position.y <= -30 && !gravityKilled) {
gravityKilled = true;
Gravity *= 3;
GravityDeathSequence(); }
// and this is working fine
currentRotation.x += Input.GetAxis("Mouse X") * sensitivity;
currentRotation.y -= Input.GetAxis("Mouse Y") * sensitivity;
currentRotation.x = Mathf.Repeat(currentRotation.x, 360);
currentRotation.y = Mathf.Clamp(currentRotation.y, -maxYAngle, maxYAngle);
Camera.main.transform.rotation = Quaternion.Euler(currentRotation.y, currentRotation.x, 0);
}
if (!hasMoveFrozen)
{
// and this is working fine
Vector3 forward = Camera.main.transform.forward;
Vector3 right = Camera.main.transform.right;
// The .normalized here scales the Vector to 1 unit size
Vector3 forwardDir = new Vector3(forward.x, 0, forward.z).normalized;
Vector3 rightDir = new Vector3(right.x, 0, right.z).normalized;
Vector3 move = (forwardDir * Input.GetAxis("Vertical")) + (rightDir * Input.GetAxis("Horizontal"));
priestController.Move(move * Time.deltaTime * Speed);
}
Your answer
Follow this Question
Related Questions
Using isGrounded with a RigidBody 2 Answers
Why does my characterController code not apply gravity correctly? 0 Answers
How can I edit this script, that it will check if the character is standing on a specific layer? 0 Answers
bizarre collision modulations with character controller 1 Answer
controller.Move doesn't stay grounded when walking down slope 3 Answers