I’m with a problem
I want to shoot the ball toward a target
I have experience with scripting, I’ve tried several ways
but the ball just did not shoot at the target
can anyone tell me what I’m doing wrong?
Vector3 shoot = ball.transform.TransformDirection(target.position);
ball.rigidbody.AddForce ( shoot*4.0f);
You are converting your target to a local position, but AddForce() takes a world position. A typical solution to this problem would be:
Vector3 shoot = (target.position - ball.transform.position).normalized;
ball.rigidbody.AddForce(shoot * 500.0f);
For a one-time application of force on an object with a mass of 1.0, you likely want values in the 250 - 2000 range depending on the situation and your goal.