- Home /
Question by
rusildo · Oct 05, 2015 at 10:55 AM ·
physicsrigidbodycharactercontroller
CharacterController applies a force to the Rigidbody object [maybe bug]
The documentation says "A CharacterController is not affected by forces" but see on gif. How it's possible? I'm use simple CharacterController and rigidbody barrels. How СС pushes them? OPEN GIF
Movement script:
private void UpdateMovement()
{
var movement = GetMoveDirection();
movement *= speed;
if (controller.isGrounded)
{
velocityY = 0;
if (Input.GetButton("Jump"))
velocityY = jumpSpeed;
}
else
{
velocityY += -gravity * Time.deltaTime;
}
movement.y = velocityY;
var collisionFlags = controller.Move(movement * Time.deltaTime);
var needAbortJumping =
(collisionFlags & CollisionFlags.Above) != 0 ||
(collisionFlags & CollisionFlags.Below) != 0;
if (needAbortJumping)
velocityY = 0;
}
3.jpg
(193.1 kB)
Comment
Best Answer
Answer by rusildo · Oct 05, 2015 at 11:58 PM
I solved problem. If set "CharacterController.detectCollisions = false" then rigidbodies not affected by CC collider.
Answer by Suddoha · Oct 05, 2015 at 10:59 AM
The CharacterController itself is not affected. However, that doesn't mean that rigidbodies cannot be affected by CharacterControllers. In the end, a CC works uses a collider as well so any rigidbody that happens to collide with it will react as if it was a normal object with a collider.