- Home /

# Drawing object projected path

Hello guys,

Currently I have a soccer game where I set the balls velocity as a vector3 (l/r, up/down/ power) and on click it is hit with that velocity via velocitychange.

At the moment the ball has a LineRenderer which draws the path it will take including gravity, and all is working perfect.

However there is one part I do not know how to implement with maths and that is the relativeVelocity of the object.

The ball has a relativeVelocity (vector3) which is added per frame via addRelativeForce. This function works perfectly, but I just need help in drawing the line it will take including its left right curvature supplied by the relativeVelocity.x.

So at the moment I have a script which draws the parabola using gravity, the ball start pos and the velocity vector =

```
void DrawMyLine() {
// y = ax^2 + bx + c
// a = grav x = time b = power c = start pos
ballLine.SetVertexCount (rpg_exp);
Vector3[] posArray = new Vector3[rpg_exp];
float a; float b; float c; float d;
float t = 0.0f; float dt = 0.2f;
float gravity = Physics.gravity.y;
float lineRelVel = relativeVelocity.x;
float posArrayLast = 0.0f;
for (int i = 0; i < rpg_exp; i++)
{
a = (gravity/2) * (t*t);
b = velocity.y * t;
c = ballStart.y;
posArray[i].y = a + b + c;
b = velocity.x * t;
c = ballStart.x;
d = lineRelVel * t; //d is the relativeVelocity on x axis
posArray[i].x = b + c + d;
//lineRelVel += posArrayLast;???
b = velocity.z * t;
c = ballStart.z;
posArray[i].z = b + c;
ballLine.SetPosition(i,posArray[i]);
t += dt;
//posArrayLast = posArray[i].x;?
//lineRelVel = posArray[i].x - posArrayLast;???
}
}//drawMyLine
```

but of course the balls x position changes slightly every frame by relativeVelocity.x, so how do I implement this change into my DrawMyLine function?

Here is what I mean : I want the black line to be where the ball goes.

Thanks for your time.

### 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.