- Home /
Question by
starscream97 · May 28, 2017 at 01:41 PM ·
rigidbodyrotatecharacter controllerroll a ball
Roll a Ball using Character Controller
Hi. I want to roll a ball using character controller. All is find is people using rigidbody. It seems to be the best way but i want to use character controller, because i had many problems with double jump,raycasting and other things when i tried using rigidbody. I can move the ball but it does not roll. Here's the code:
if (controller.isGrounded)
{
verticalVelocity = -0.5f;
}
else
{
verticalVelocity -= gravity * Time.deltaTime;
}
moveVector = Vector3.zero;
moveVector.x = Input.GetAxis("Horizontal");
moveVector.z = Input.GetAxis("Vertical");
moveVector.y = verticalVelocity;
controller.Move(moveVector * Time.deltaTime);
}
Comment