Download

Fear Bar Mechanism

Hello everyone,

I am working on a mechanism which I couldn’t find any reference to online as a tutorial so I thought someone here could help me with it.

I am trying to create a “Fear Bar” Which does the following:
Starts as 0, Max is 100, The number grows as you come closer to a scary item and goes back to 0 gradually as you get away from the object. This is easy and I’ve done it.

What I am stuck with is trying to also make it also grow through time, as in every second the fear bar will add 1 every seconds meaning after 100 seconds you will die. I have done that with a normal timer for the game and it worked for the timer but not the Fear Bar

Now, the most complicated thing I couldn’t also even figure out “and I hope I will be able to explain”, is that If your current fear is say “10” Already and you come close to something scary which will obviously raise your fear. I want the number to go back to “10” When you get away from that object instead of going all the way to 0.

I was thinking maybe the solution is to hook the fear factor to the timer maybe?

I hope I explained what I want clearly but in case I didn’t please don’t hesitate to ask.

About the fear bar growing through time, I would have a timer which starts on character begin play which is obviously a looping timer with time set to 1. Then you would have a function/event which adds 1 to the fear bar every second. Basically you just get the current amount and add 1 and set the new amount. You can also check at the same time if it’s a certain value etc so player dies or does whatever you need them to. I’m not sure I understand when you say “I have done that with a normal timer for the game and it worked for the timer but not the Fear Bar”. There is on reason why this would not work.

As for the complicated thing. So when you interact with something that raises you fear, set a variable which holds the value it is at that time, and when you are reducing the fear, just set a minimum value of that number.

Not sure if i’ve been helpful.

Hello Jimminy, Thank you for reply it was more than helpful.

  1. Sorry, but English isn’t my first language in case I can’t get my message across clearly. What I meant here "“I have done that with a normal timer for the game and it worked for the timer but not the Fear Bar”. Is that I created a normal timer where the game ends at 00:00 as in a count down timer. and I know how to create a timer that goes +. This function “The Round Timer” Is working perfectly no problems at all.
  2. Now regarding the fear mechanism, I successfully made it go (+1) when you get close to something scary and (-1) when you go close to say a friendly character lets call this (FUNCTION 1). Now, here is the problem with (FUNCTION 2), I want adding to that the factor that when you are close to neither, your bar should go (+1 per second). I did both “functions” successfully, When the game starts you see FUNCTION 1 working perfectly, the problem starts when FUNCTION 2 is activated, once I get away from any character FUNCTION 1 stops working.
What I want is that when FUNCTION 2 stops, you go back to the number where FUNCTION 1 stopped, as in if you had 10 fear and you came close to an enemy and your fear went to 90. and then you ran away from the enemy, you go back to 10 fear and not 0. and then you keep going +1 per second from 10 fear.
  1. Can you explain to me or refer me to an online tutorial that does this “As for the complicated thing. So when you interact with something that raises you fear, set a variable which holds the value it is at that time, and when you are reducing the fear, just set a minimum value of that number.”? I am new to the engine.

An example of a timer used for adding to fear every second until full. This would go on begin play for the character

As for 3, an example is below. This is all dependent on how you functions operate. It is also just a quick example and would require refining. If you are not setting the value straight away but rather using a timer to slowly decrease it when player moves away, you will need to pause the timer that increases fear every second until you have reached the value needed and then unpause it.

Didnt know I could add images directly :smiley: This is my Fear Timer

This is for when my character gets out of a dangerous situation and the opposite will me “+” instead of “-” When he enters a dangerous situation