Bounce into the air

0

Hi guys

I’m working on a 2D game, and I need a projectile prefab bounce/flap/jump in the middle of the air after the player press the mouse. In this case, while it moves along the X-axis, it is necessary to apply a force inversely proportional to the projectile’s angular direction on the Y-axis in relation to its own x-axis line (only when it has a negative angle in relation to the horizontal line). The new velocity should be minimally lower than the previous one, divided by the percentage of “SlowDownFactor.” Something like that:

I’m new to Unity, so I don’t know exactly which commands to use to apply this inverse force, I’ve already taken a good look at the documentation, but I haven’t been very successful. The code I have so far:

{
    [Range( 0, 1 )]
    public float SlowDownFactor = 1;
    private Rigidbody2D red_rigidbody;


    public void ExecuteAirSpecial()
    {
        red_rigidbody = GetComponent<Rigidbody2D>();
        Vector3 redAng;
        red_rigidbody.AddRelativeForce(Vector3.Angle(redAng.y, -redAng.y) * SlowDownFactor);
    }
}

[Range( 0, 1 )]
public float SlowDownFactor = 1;
private Rigidbody2D red_rigidbody;

     public void ExecuteAirSpecial()
     {
         red_rigidbody = GetComponent<Rigidbody2D>();
    
         red_rigidbody.AddRelativeForce(Vector2.Perpedicular(transform.forward) * SlowDownFactor);
     }

try this, it adds a force to the direction perpdicular to the objects forward (normal in your image)