- Home /
Moving a ball up a hill
I have a ball that is stuck in a valley between two hills. I am trying to add torque to make it move up the hill, but it doesn't work. Here's an image of that https://ibb.co/g2RRrR.
This is my player script:
private float constantSpeed = 5000000;
private void Awake()
{
this.rigidBody = this.GetComponent<Rigidbody>();
this.rigidBody.maxAngularVelocity = 100000000000;
Debug.Log(this.rigidBody.maxAngularVelocity);
}
private void Update()
{
if(Input.GetMouseButton(0))
{
var myForward = transform.right;
Debug.Log("Adding force");
this.rigidBody.AddTorque(Vector3.forward * -constantSpeed, ForceMode.Force);
}
}
No matter how high my torque is, the ball just doesn't move up the hill. Am I doing something wrong?
Not sure why it didn't get uploaded. Anyways you can try this link. https://goo.gl/images/7Q3RC8. The ball is stuck in between and does not move up. It moves a little and then comes back down.
Answer by JustinTheSwift · Oct 24, 2017 at 05:45 PM
I have no clue how to do this in Unity, but in real life the answer would be friction. Something can spin all day, but it it's a tire in the mud and there's no grip it won't go anywhere. Maybe you can add some friction somehow.
Your answer
![](https://koobas.hobune.stream/wayback/20220612141745im_/https://answers.unity.com/themes/thub/images/avi.jpg)