dash towards mouse position? (New Input System)

I am making a multiplayer game, where a main mechanic is the ability to dash towards the mouse. After quite a bit of pain, I have worked out all of the inputs. Now here’s the issue: I don’t know how to actually make the player dash. I have the button to start the dash, the timer for the dash, and the mouse/controller input set up. I know how to use things like “rb.velocity” or “rb.AddForce” But, I don’t know how to take my input’s Vector2 and actually apply it to the dash ability, to control the direction. Does anyone know how I might do this? Here’s the code I currently have:

    public void Dash(InputAction.CallbackContext context)
        // dash when dash button is pressed (dash button and the timer are handled in another void)
        if (startDash == true)

            Vector2 DashAim = context.ReadValue<Vector2>();


            startDash = false;



Is your game 3D? If so, do camera.screenpointtoray on dashaim, where camera is your main camera. Use a physics raycast on that result to cast a ray into your scene. The hit result’s point will give you the point you want to dash towards. You can do (point - player position).normalized to get the direction you want to dash in.

If it’s a 2D game, you can just do (dashaim - player position).normalized to get the direction.

when you use rb.AddForce it asks you for a direction vector this direction is basically the vector going from your character to the mouse simply get the mouse global position and substract it to your player’s position this will give you thatdirection vector, in case of a 2d game it will return a 2d vector, if not just add 0 as the Vector3’s Z value. then you use AddForce as you know it