Hey, everyone, I’m building a game involving firing a shot from a cannon and I want to be able to have the projectile speed/distance be based on the progress bar, like turtle toss or kitten cannon. How can I control the power of the shot based on the progress bar?
First you break your problem into simple tasks. For your game is “how umg works” and “how to shoot physics body”
then google for tutorials about “unreal umg” and about “unreal physics”
then you follow those tutorials, and finally you make your game.
I have the progress bar built and even have a slider to control the percentage of the progress bar just curious how to have my character fire further based on if the progress bar is set at 1% or 100%
I even have my character firing on a button clicked i just would like to tie in the progress bar to determine the distance and power
If your projectile is an actor and you are creating it using a “Spawn actor from class”, you can set up a variable (probably a float) on your projectile actor that is “editable” and “expose on spawn”. Then, wherever you run the “Spawn actor from class”, you will be able to pass in a value for that float. In your projectile actor, on begin play, use the passed in variable to set the velocity in the projectile movement component. You could use the value passed in as a percentage and multiply it by a “Max Speed” to perform your calculation.
ill try that out thank you
Looks like you would need a BP/code that calculates that and can be accessed by everyone. Try doing this in GameMode.