Hi, this is my code, I need to create a line that will predict and indicate where my projectile will fall

Hi, this is my code, I need to create a line that will predict and indicate where my projectile will fall

float startTime;
public GameObject Bullet;
public Transform point;
private float speed = 4f;

private void OnMouseDown () {
    startTime = Time.time;
}
void OnMouseUp () {

    float forse, dif;
    dif = Time.time - startTime;

    if (dif < 3)
        forse = 10 * dif;

    else
        forse = 20;

    if (forse < 6)
        forse = 6;

    GameObject bull = Instantiate (Bullet, point.position, point.rotation);

    bull.GetComponent ().AddForce (point.transform.right * forse, ForceMode2D.Impulse);
}

Predicting the physics engine is NOT easy. (I’ve never had any luck with this when applying forces are involved.)

I would suggest you either:

NOT use the physics engine to compute the projectile’s actual path: instead, use your own formula to compute both the line AND the projectile’s actual path. (e.g. a simple parabolic trajectory formula)

OR

Create an invisible rigidbody with the same properties as the projectile, and let it run through the physics engine, recording it’s position each frame. Then use these recorded positions to draw the line.