Launch an object in-game depending on how long the player has held the left mouse button on it?

When clicked, the object will start to build power. When the mouse is released, the object should be launched upwards based on the time spent building power. How would I do this?

When the player clicks, look at the game time. When the player releases, do the same.

The difference is how long the button was held. Then you can add force ( or whatever ) accordingly.

very easy
1- you will create a float variable called “LaunchPower”
2- when the mouse is pressed the variable will be updated [LaunchPower" + 1]
3- if the mouse is released it will launch the object
4-now you can use the value of the variable “LaunchPower” as you want
5- reset the “LaunchPower” variable value to 0 again
Hope that helped.

When clicked […] the object should be launched upwards based on the time spent building power

Use Enhanced Input:

image

1 Like

I was unable to get any of these to work for some reason


I managed to get it to work with this

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.