Announcement

Collapse
No announcement yet.

Gradually charging progress bar

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    That's the DeltaTime pin on the Event Tick node.

    Leave a comment:


  • replied
    Originally posted by Antidamage View Post
    I'd refactor it a bit:

    bool CanFly = true;
    bool IsFlying = false;
    float FlyingEnergy = 1.0;

    Event Input Tab -> CanFly? IsFlying = true;
    Event Tick -> IsFlying && CanFly = true? FlyingEnergy -= SecondsPassedThisTick/100; Add upwards force;
    Event Tick -> IsFlying = false? FlyingEnergy += 0.1;
    Event Tick -> FlyingEnergy < 0? CanFly = false;
    Event Hit -> Did we hit the ground actor? IsFlying = false; CanFly = true;

    If you want it to recharge during falling, set IsFlying to false as soon as a the key is released rather than when they hit the ground.

    Doing stuff on event tick in this way isn't recommended for secondary actors, of which you might spawn a lot. Ideally you structure this in such a way that when the energy is full and the character isn't trying to fly, nothing happens.

    Hey, thanks for this input - looking at the "IsFlying && CanFly = true?" Where do I get the SecondsPassedThisTick or rather how do I get the number of seconds after each tick?
    Last edited by socir; 12-15-2015, 02:25 AM.

    Leave a comment:


  • replied
    I'd refactor it a bit:

    bool CanFly = true;
    bool IsFlying = false;
    float FlyingEnergy = 1.0;

    Event Input Tab -> CanFly? IsFlying = true;
    Event Tick -> IsFlying && CanFly = true? FlyingEnergy -= SecondsPassedThisTick/100; Add upwards force;
    Event Tick -> IsFlying = false? FlyingEnergy += 0.1;
    Event Tick -> FlyingEnergy < 0? CanFly = false;
    Event Hit -> Did we hit the ground actor? IsFlying = false; CanFly = true;

    If you want it to recharge during falling, set IsFlying to false as soon as a the key is released rather than when they hit the ground.

    Doing stuff on event tick in this way isn't recommended for secondary actors, of which you might spawn a lot. Ideally you structure this in such a way that when the energy is full and the character isn't trying to fly, nothing happens.
    Last edited by Antidamage; 12-13-2015, 07:44 PM.

    Leave a comment:


  • replied
    Originally posted by Echosyp View Post
    Are you wanting it to charge only when you take damage? or every few seconds also? not hard to setup.
    Well, I have a character that can fly whenever the "tab" key is pressed and I want to limit how long he can stay flying. The idea is when the tab key is pressed and he starts flying, I want a progress bar called "Flying Energy" to show how much flying stamina he has left. When the progress bar reaches zero flying will be disabled until the flying progress bar recharges. I tried doing this:

    1. Create a variable called "inAir".
    2. Create a variable called "flyingEnergy".
    3. When flying key is pressed, set "inAir" to true.
    4. During "Event tick" when "inAir" is true "Delay" for 1 seconds then start subtracting from "flyingEnergy".

    ------this is where things get a little confusing-------

    a) How can I subtract from "flyingpower" every second "inAir" is true?
    b) How can I send the value of "flyingpower" to a progress bar so it shows how much flying energy is left before the character will fall to the ground to recharge "flyingpower"?
    I'm not very familiar with the many available nodes and can't figure out which ones would work best for the job.

    Leave a comment:


  • replied
    Are you wanting it to charge only when you take damage? or every few seconds also? not hard to setup.

    Leave a comment:


  • replied
    Thanks for sharing. Unfortunately, I couldn't get the setup to work for what I wanted.

    Originally posted by Echosyp View Post
    Event Tick flow:

    Part1: http://prntscr.com/9dgerw

    Part2: http://prntscr.com/9dgfio

    It's a very messy BP as it's being used on a 2d game i started making and haven't touched in a while.

    Leave a comment:


  • replied
    Event Tick flow:

    Part1: http://prntscr.com/9dgerw

    Part2: http://prntscr.com/9dgfio

    It's a very messy BP as it's being used on a 2d game i started making and haven't touched in a while.

    Leave a comment:


  • replied
    Oh nice, can you show a screen capture of the event tick flow.

    Leave a comment:


  • replied
    You can do it pretty much the same way you would a stamina bar.

    I have a widget with my stamina bar on it and created a function called: Get Stamina From Player that looks like this:

    Click image for larger version

Name:	UKGHXbm.png
Views:	1
Size:	106.3 KB
ID:	1094962

    Then on my character BP

    I have an Event Tick that will check my players movement and if he is running then the stamina bar decreases and if he is not running then it will slowly fill up.

    Then I have a float variable called Stamina Value set to 100 that all that references to.

    Leave a comment:


  • started a topic Gradually charging progress bar

    Gradually charging progress bar

    I've been looking around for examples of progress bars that gradually charges whenever a player takes a damage or uses up available energy. I couldn't find anything or examples to learn from. I was wondering if anyone here had any examples they can share. Better yet, if you have some ideas on how to make the progress bar charge every few seconds, I would be interested in learning how you put it together.
Working...
X