Hello everyone, can someone explain me (i am novice) how to write a code to roll a ball when i am using CharacterController to move the ball?
Character controller in Unity is capsule-shaped. Not sure if you can get there from here.
Maybe you can though… give it a try. Work through some character controllers until you understand better than my superficial understanding how they work, then try your hand at a roll-a-ball tutorial and see if the two can meet in the middle.
There are hundreds if not thousands of tutorials for each thing already out there on Youtube, no point in someone here making you a fresh one.
Assuming you mean that the player is the ball (and you’re not bowling a ball), you could look at the Roll-a-ball tutorial for ideas:
i know how to roll a ball with rigidbody but i just want to roll it with character controller
it is possible ?
Come back and tell us all how it went. We’re not going to conduct your experiments for you.
Its not very clear what you mean by “roll a ball” and “move the ball”.
If you mean the CharacterController IS the ball, then its a matter of how you define the moment behavior, which basically means you’re writing your own physics behavior for a rolling ball.
If the CharacterController is pushing a ball, CharacterController collision and Physics collision are not-really-but-kinda separate from each other. Collision with static colliders is fine since the CharacterCollider is moving into the static collider, and is stopped by whatever static collider they collided with. Collision with physics enabled rigidbody colliders however, will not happen while the CharacterController is not moving. There are however tricks like overlaying a capsule collider over the CharacterController capsule, to allow the CharacterController to seemingly collide with other rigidbodies.
Hey there if anyone comes across this or on the off chance you guys are still looking for the answer, the easiest thing to do is use an empty game object with the character controller component, and your controller script(s), and a sphere as a child object. Attach a script to the child sphere, or add code to your player controller, to rotate the sphere on its local X axis based on the Z velocity of the character controller component. Hope this helps!
Also in case youre looking for the character controller to “kick” or “push” a sphere with physics, simply add a sphere as a child object somewhere under your player parent, and give it a kinematic rigidbody, then disable the MeshRenderer component. This will interact with any rigidbody physics in the game world like HingeJoints for doors, and knocking things over. We call them “BumperSpheres”(Around the players chest), or “KickerSpheres”(around the players feet.)