So I’m creating a floating vehicle, I tried to add a feature like boosting and the fuel for boosting can be empty,
I made 3 boolean variables that are “Boosting?, Can Boost?, and Move Forward?”
the default Value for these Variables :
(Can Boost?) “Yes” because when the game is started, the fuel is 100%.
(Move Forward?) “No” because when the game is started, car is not moving.
(Boosting?) “No”
My guess would be that your MoveForward bool is set to true immediately, because Input Axis Forward event will always fire (with zero Axis Value if nothing pressed). So you should compare current Axis Value with zero before setting MoveForward to true.
So I made this blueprint. It is the same for the most part, but there are a few changes. Let me give you a quick summary:
On tick: If the boosting? variable is ‘yes’ and it has fuel it will start to decrease your boosting fuel. Also If the Boosting Fuel is equal or less then 99 (Always use =< or => in a tick event. Using = can cause bugs when used in tick events) it will start to refuel your boost fuel and reset your speed and set ‘boosting?’ to ‘no’.
You can also remove the boost fuel refuel if you wish to do this in another way (for example if you are at a gas station, ‘boost fuel’ will be set to 100)
Pressing and releasing the W button will set the ‘moving forward?’ variable to ‘yes’ or ‘no’.
You can change the button if you use another key for moving forward. Also if you want moving forward to be on toggle, simply place a switch between pressed and the Boolean. Remove the link from released and placed it into B of the switch.
When the boost button is pressed it will check if the boost fuel is equal or greater then 1 (in other words: if you have fuel) and if ‘moving forward?’ is ‘yes’. It will then adjust the movement speed and set ‘boosting?’ to ‘yes’. If those conditions are not met, or the button is released, it will set the movement speed back to the default max speed and set ‘boosting?’ to ‘no’.
You can of course change the character max movespeed to a custom float variable if you have this set up.
You could choose to apply force like you did, but if your movement speed is set by a tick event (for example: inputaxis) you can simply change the max movespeed as it will keep adding up to that until the max is reached.
I hope this helps
If you need anything else added to this, let me know
No, you don’t want to set it haha. What he meant was to check if the axis forward value is not 0, so that it’s only getting set to true when you move forward. To check that you need a branch. Like this.