Click and drag jump mechanic

So I have a simple platformer game where the player can run and jump, nothing too fancy. But I thought it would be really interesting if the player could click and drag to indicate the direction of the force rather than just jumping up every time.

I’m pretty new to unity and scripting so this is kind of a broad question for anyone to offer some ideas. I don’t mind watching tutorials I’m just not really sure where to begin!

Thanks in advance if anyone wants to help out!

the game is 2d idk If that helps at all

How I would do it is that I have just a transform, nothing more and on that transform I have a looking script. When (input.getmousbuttondown(0)) is called the transforms forward would point to the cursor and when you stop holding the mouse down you get projected towards the cursor.

   private bool canJump;
    
    public void Update()
    {
    if(input.GetMouseButtonDown(0) && !canJump)
    {
canJump = true;
    (Insert a clever 2D transform looking script).
    }

if(Input.GetMouseButtonUp(0) && canJump)
    {
    this.GetComponentInParent<RigidBody2D>().addForce("to cursor the");
canJump = false;
    }

This is a really bad and sloppy script but I can’t test things now because I don’t have Unity installed at the moment but you get the idea. Hope this helps :slight_smile: