How can I create a projectile toss similar to Pikmin and display trajectory in a debug mode

Godot Version

4, C#

Question

So I am trying to make a game where you can throw bombs like in bomberman but using Pikmin like throwing physics.
I am horrible with math and I understand this would take some trig knowledge.

So far I know I need:

  • A starting point
  • An end point (the cursor’s 3d space)
  • Object Mass
  • Gravity
  • Power of the throw/Time/Speed
  • Friction
  • Angle thrown
    What I have is:
  • A starting point
  • An end point
    And the rest would need to be calculated or taken from godot properties.
    My issue is reasonably combining these all to get a proper throw.

This is the best code I have but it doesn’t really replicate what I want especially when height differences occur.

Code:

    public void Move(Vector3 startPos, Vector3 endPos)
    {
        _body.LinearVelocity = CalculateLaunchVelocity(startPos, endPos, GravityComponent.Gravity, BombHeight);
        //_body.LinearVelocity = CalculateVelocity(startPos, endPos);
        //_body.ApplyCentralImpulse(CalculateVelocity(startPos, endPos));
    }

    public static Vector3 CalculateLaunchVelocity(Vector3 startPosition, Vector3 endPosition, float gravity, float desiredHeight = 5f)
    {
        // Calculate displacement between start and end
        Vector3 displacement = endPosition - startPosition;

        // Find time required (assuming the y-axis represents vertical motion)
        float time = Mathf.Sqrt(2 * desiredHeight / -gravity);

        // Calculate vertical velocity
        float verticalVelocity = -gravity * time / 2.0f;

        // Calculate horizontal velocity
        float horizontalVelocity = displacement.X / time;

        // Combine into the final launch velocity
        return new Vector3(horizontalVelocity, verticalVelocity, displacement.Z / time);
    }

Visual sample:
Godot_v4.1.1-stable_mono_win64_4GTm0QZdK3

Any help is appreciated. I would also love to somehow simulate where the bomb would land from this function without tossing it when debug is on.