Hi all, I’m trying to create a shoot system for a football prototype. I’m starting with very basic IA behaviours working in a State Machine. Unfortunately, I’m having problems with the shoot state direction. My current objective is to make the player always shoot at the center of the goal, but this only happens if the ball is centered towards the goal, if I change the ball position for one side or the other, the normalized direction presents a slight variation for that side. To check if the normalized vector was right, I end up using Debut.Ray and the ray is actually pointing at the center of the goal, so I can’t understand what is making the shoot vary based on the ball position.

Will try to sum up my codes here:

Shoot state script:

 var finalShootDirection = (shootTarget - ballController.ballPosition).normalized;
 Debug.DrawRay(ballController.ballPosition, finalShootDirection * 30, Color.cyan, 5);
 ballController.AddForceToBall(finalShootDirection, shootPower);

BallController’s AddForceToBall method only has this:

 public void AddForceToBall(Vector3 ballDirection, float power)
     {
         ballRB.AddForce(ballDirection * power);
     }

To illustrate things better, there are 2 images below:

The problem is that the player who touches the ball apply a very small amout of force because of the collision itself, that force is what was causing the little distortion in the shoot direction.