# Predicting the hit point on X axis, based on vector direction

Hey guys, I'm working on the behavior of the goalkeeper of my soccer my game. This is what he's supposed to do: once a player kicks the ball towards the goal, it calculates the point where the ball is going to hit the goal, then jumps towards it once the ball gets close.

Yea Raycast would work wonders, BUT this is gonna be calculated on server side, where I can't use Unity, nor Raycasts nor Colliders, so I gotta use pure math. I've found few similar questions here but the solution allows the use of raycasting and other unity resources, which isn't possible in this case.

**So, this is the data that I already have:** the direction of the kick, calculated by

```
(kickDestination - ball.position).normalized;
```

**This is what I want to do:** calculate the point on axis X where the ball is going to hit.

**This is what I've done so far:** I can position an object ahead of the ball while it's being kicked, then I can detect the point where this object collides with the X axis, but I wanna try some solutions based on math only. I'm using the following line

```
dummy.position = ball.position + ball.direction;
```

**The following image explains it better.**

**Answer** by Happy-Zomby
·
Apr 04, 2016 at 10:21 PM

Hi, If you look here https://www.mathsisfun.com/algebra/trig-solving-asa-triangles.html

For your starting angle (the one at your kick origin) you can use this. http://docs.unity3d.com/ScriptReference/Vector3.Angle.html This will be angle b.

Then you have a 90° angle. If you go straight from your ball to the end of pitch line. So angle a is 90.

And you can also calculate that distance. The distance is the Base of your triangle between a and b.

With that you can get the left side of your triangle and get your prediction point by adding that to the x of your point on the pitch line we calculate earlier.

You can find sin and so on in the MATHF functions.

Hope that helps,

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.