x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Alternate between calm and heavy breathing based on oxygen value

Hey guys,

My first post here but not my first time here. Spent many MANY hours reading through posts, mainly to find solutions to problems I've faced with blueprints and getting certain aspects of my game working. I am very VERY new to blueprints with no coding knowledge, I am primarily a 3D/2D Artist, EEKS.

Now on to my current problem. I have a player who has an oxygen bar which constantly goes down as you can see from my OxygenLeak Function image below. I also have an Oxygen Thrust which minuses from the oxygen amount. All of this works great, I have pickups too that add oxygen with a clamp to ensure the oxygen value will max out at 100.

Now what I want to do, and I have tried and TRIED, is have my players breathing change from calm to gasping when the oxygen value is below 50 (the max is 100) via the Oxygen variable. I can not for the life of me get this to work. I believe it is due to the fact in the character blueprint only the starting value is being read with is 100 and not the 'live' value do only the calm breathing plays with no change once oxygen goes below 50.

I have tried adding this to an event tick but that just plays the audio every second and managed to get it to work using a do once but then had difficulty reverting back to the sounds when oxygen went over 80, it would not repeat without the crazy sounds playing every second.

I'm not sure if I'm making much sense, especially after spending so many hours trying to figure this out! :(

Please help!

Product Version: UE 4.11
Tags:
more ▼

asked Apr 09 '16 at 10:03 AM in Blueprint Scripting

avatar image

TutorJay
11 1 3 3

avatar image TutorJay Apr 09 '16 at 11:57 AM

Thank you both of you! It worked! I have attached the blueprint for the breathing control. I ended up using a sequence as it's the only way I know of to allow more than one output from an event tick.

Doe this look ok?

alt text

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

This may not be the best solution but personally I'd go for a event system. Where you trigger some custom events based on the oxygen change.

That adds at least some layer of abstraction and makes the graph a bit smaller when working with it.

Next of all event Tick is actually very right. You need to check all the time. If you have it once at the beginning it will only be called once, compare the initial value and never change because that part is never called again.

DoOnce is a good start. You want to add that right after checking for a value. So let's say you check if it's below 50. If so, DoOnce, call your heavy breath event and reset all other DoOnce.

Then check if it's above 80. If so, DoOnce, call your normal breath event and reset all other DoOnce.

(Do Once will only allow one input through. Until something enters "Reset". Then it will allow one more impulse through until "Reset" is called again).

And the separation in events is simply so you can rather easily add more effects later on. Like HUD modifications and the likes without going in the actual checks and moving tons of stuff around.

Does that make sense?

more ▼

answered Apr 09 '16 at 11:29 AM

avatar image

Erasio
5.9k 291 86 293

avatar image TutorJay Apr 09 '16 at 11:57 AM

It worked, Thank you for you help! :) I have added a comment with my new blueprint. Does it look ok?

avatar image Minus_Kelvin STAFF Apr 11 '16 at 05:43 PM

Thanks a ton Erasio!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

If I understand you correctly, you could put a branch right after the tick that is doing your oxygen calculation that tests if current oxygen < 50% of max oxygen, then use a sequence and a do once node after each branch result. First output of sequence plays the sound (and stores it to a variable) and the second goes into 'reset' on the opposite branch. Then go into your sound asset and set it to looping.

more ▼

answered Apr 09 '16 at 11:30 AM

avatar image

SVR33
163 14 20 32

avatar image TutorJay Apr 09 '16 at 11:58 AM

It worked, Thank you for you help! :) I have added a comment with my new blueprint. Does it look ok?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question