- Home /
Question by
piemanpie · Feb 12 at 09:19 PM ·
charactercontrollergravitycharacter movement
i clip into my walls with a character controller
Hello i keep on clipping into my walls and i have no idea why. I am using a character controller and i have changed the step offset and i am really lost. Also i will just go through any slopes or stair and my players y will not increase. this is my code thank you.
bool isGrounded;
// Update is called once per frame
void Update()
{
isGrounded = Physics.CheckSphere(ground.position, groundDistance, groundMask);
if (isGrounded && velocity.y < 0) {
velocity.y = -0.1f;
}
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * speed * Time.deltaTime) ;
velocity.y -= gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
}
}
Comment
Your answer
Follow this Question
Related Questions
Gravity not working 1 Answer
Low fps issues for character movement 0 Answers
Smooth walljumping 0 Answers
Jumping Stopped Working. 2 Answers
My player is stuck on left and right side(Endless Runner) 0 Answers