Skip to main content
added 305 characters in body
Source Link

I think a normalized vector from the ball to the object.

direction = (ball.transform.position - kicker.transform.position).normalized;

I made a game doing kind of this thing you are doing. (source code link in the post) http://luigigarcia.byethost7.com/projects/goal-a-r-goal/

I think that your kicking object must do this work, not the ball. You need to know the ball someway:

  • reference set in some component;
  • through the OnCollision MonoBehaviour methods;
  • etc..

You apply the direction with something like this:

  ball.theRigidbody.AddForce(direction * powerValue);

I think a normalized vector from the ball to the object.

direction = (ball.transform.position - kicker.transform.position).normalized;

I made a game doing kind of this thing you are doing. (source code link in the post) http://luigigarcia.byethost7.com/projects/goal-a-r-goal/

I think a normalized vector from the ball to the object.

direction = (ball.transform.position - kicker.transform.position).normalized;

I made a game doing kind of this thing you are doing. (source code link in the post) http://luigigarcia.byethost7.com/projects/goal-a-r-goal/

I think that your kicking object must do this work, not the ball. You need to know the ball someway:

  • reference set in some component;
  • through the OnCollision MonoBehaviour methods;
  • etc..

You apply the direction with something like this:

  ball.theRigidbody.AddForce(direction * powerValue);
Source Link

I think a normalized vector from the ball to the object.

direction = (ball.transform.position - kicker.transform.position).normalized;

I made a game doing kind of this thing you are doing. (source code link in the post) http://luigigarcia.byethost7.com/projects/goal-a-r-goal/