Hello
I want to rotate a ball arounf itself while it moving and I applied that code and it didn’t rotate
if(Input.GetKeyDown("right")){
transform.Rotate(Vector3(0,0,1) * Time.deltaTime );
moveDirection.x = 2;
controller.Move(moveDirection * Time.deltaTime);
}
Is there any help guys to do it?
Would this help?
If not, you could use an Update() and transform EulerAngles(). Just set an increment, if pressing btn, rotate ball by this amount on this axis.
Thanks buddy but it does not help here
why not? Even the setting EulerAngles(), from what you asked I would think it would.
I added a rigidbody torque component to it and it does not rotate also
here what I `ve done
if(Input.GetKeyDown("right")){
rigidbody.AddTorque(0,0, 10);
moveDirection.x = 2;
controller.Move(moveDirection * Time.deltaTime);
}
And this does not work? What type of collider, if any are you using? Why do you need a rigidbody? Also physics updates are handled by FixedUpdate().
No it does not work… I am using Character Controller not using a collider… I used the rigidbody to apply Torque
what exactly are you going for? Do you want a ball to roll down a hill? Are you using real world physics? Are you making it fly through space?
I am making a small basketball game and I want the ball to roll when it moves on the floor or the space, Yes I`m using real world physics
You seriously want to make a function that controls the roll?? Waste of time. Create a sphere collider, with a rigidbody, uses gravity, of mass x and let the physics engine do its magic. By nature, if you shoot the ball, and it it ricochets it will have spin.
Yes my friend that`s what I wanted to do, but you know when the ball be the character controller it is not supposed to use rigid body with it but I will give it a try 
My suggestion is this. I have talked to others about a basketball game. My idea was, that when the ball is in possession of the player, that the ball.rigidbody.enabled = false, ball.collider = false, ball.renderer.enabled = false. And instead of trying to manage the very difficult physics of ball dribbling, which involves so may factors, use an animation. Have a stand while dribbling animation, run with ball dribbling animation and a stand with ball not dribbling animation.
When you pass or shoot, reactivate the ball, alter the animation and bob is your uncle.
Thanks buddy, At first I was making gravity calculations by formulas like this :
var controller : CharacterController = GetComponent(CharacterController);
if(controller.isGrounded)
{
if(Input.GetKey("right")){
rigidbody.AddTorque(0,0,10 * Time.deltaTime);.
moveDirection.x = 0.2;
controller.Move(moveDirection * Time.deltaTime * speed );}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
but I removed this formulas and used rigidbody only with sphere collider and it works a bit close as I want it to do.
Your welcome!!!
I expect 30% of profits!!!
Harhar.
::))( yah, use animation for dribbling. The physics involved may be simple to most humans, in the real world but it is a complex function with many players player!
30% Only!!!
LOL … just pray for me to find the assets to complete the projects dude 