How would i make a left click drag mouse then release to fire an object?

Details :
I am working on a golf game at the moment. I already have a working model made but i want to change how i power up the force and apply it. Currently i am holding down left mouse button and it is using the delta to generate a power force that i then apply to the ball upon pressing space. but after a bunch of testing this model is hard for fine tuned shots where you want to use a specific power amount.

Question:
What I need help with.
what I have in my vision is on left click pressed i would like to enable me to either move my mouse up or down on my mouse pad to create a power reference. I have tried getting mouse position and stuff but in my game there is no cursor and it doesn’t work right or I don’t know how to make it work.

if you ever played like angry birds or golf with your friends or a simple launch mechanic for pinball where i would just click then drag mouse to generate a power force. any help or direction would be great as i have tried endlessly searching but everything I find does not help me when i replicate their solutions.

See if this gets you any closer:

Not sure if you need Direction, you can just use the magnitude, with some clamps perhaps.

Image from Gyazo

1 Like

Depending on what you need, you could project a vector onto another vector, if you need distance in a fixed direction based on another factor:

Or if you’re only after 1 dimension:

You did not really mention how you obtain the desired direction, so I took some liberty in assuming things here.

And if I wanted to build up force based on mouse delta, I’d accumulate it like so:

Here, we don’t care where the mouse cursor is.

Image from Gyazo

THANK YOU!

this definitely put me on the right track I will have to tweak some things as i play around but this gets me going in the right direction THANKS! What I have been using is player control rotation to get the direction that I send the ball and a simple arrow component to visualize the direction. thank you for taking the time to do this for me!

UPDATE
I have since scraped that game I was working on. But i have started from scratch with a new golf game and i wanted a Golf With Your Friends style power for the shot when you click drag mouse release

How I went about doing it this time is

is saving the mouse position on LMB Pressed and on LMB Released and take the difference of the Y value and using this as my power variable.

Hope this helps someone who may need something like this

1 Like

I’m also looking for the same concept of Golf with Friends. I’m hoping that I can figure out why it’s not working for me.

what kind of structure variable are you using for power up start and end mouse position?