void UpdateTrajectory()
{
Vector2 position = transform.position;
Vector2 nextPosition = position;
Vector2 velocity = force;
if(player.getDirection())
{
velocity.x = Mathf.Abs(velocity.x);
}else
velocity.x = -Mathf.Abs(velocity.x);
int i = 0;
do
{
//Debug.Log(i + " " + velocity);
points.Add(new Vector3(position.x, position.y, z));
nextPosition += velocity * timeSeg + 0.5f * Physics2D.gravity * timeSeg * timeSeg;
// Raycast for collision
RaycastHit2D hit = Physics2D.Linecast(position, nextPosition, mask);
if (hit)
{
Vector2 point = hit.point;
points.Add(new Vector3(point.x, point.y, z));
drawLine();
return;
}
position = nextPosition;
velocity += Physics2D.gravity * timeSeg;
} while (++i < maxVerts/* && !collision*/);
drawLine();
}