Issues trying to create a stamina system

I’m super fresh with learning Unreal so this is probably jumping way too far into the deep end but I really want to try and figure this problem out.

I’ve been trying to replicate the stamina system in this tutorial

I want to implement this for first-person game instead though.

I’ve got to a point where I’ve replicated everything in the tutorial but for some reason, my stamina isn’t regenerating. I also can’t run again once I’ve activated sprint once.

I’m also getting this error after stopping play

Changing the ‘Mesh’ node to ‘First Person Mesh’ fixes this but I’m wondering if this is part of my problem because the 3rd person template doesn’t have these 2 different meshes.

This is my input mapping Blueprint, which I believe is slightly different to the 3rd person default too.

Everything else is 100% identical to what’s in that tutorial video. I’ve gone through it 3 times now and double checked everything.

Again, I know I’m in way over my head but I really want to figure this out.

Hey @magumb0s! Welcome to the forums!

Can you show all of your code starting with your run_roll_avoid event? That includes the insides of any custom functions. Get that to us and we’ll take a look, I see this quite a lot. Don’t worry, it’s usually a quick fix, and a symptom of looking at your own code for too long. :slight_smile:

Get that back to us and let’s get you sprinting along!

The GAS system is great for things like this. Building an attribute and effect system in c++ makes it pretty is easy to implement and replicate in BP. It’s more than I will explain here but I follow Alamars Dev Domain on YouTube. His series on GAS, especially the top down shooter one is a really easy and good start for setting this up if your not afraid to dive into some c++

1 Like

Thanks so much. Unfortunately, as a new user, it’s only letting me include one picture per post so let’s start with the run_roll_avoid event and I’ll try post everything else separately, as annoying as that is

Handle stamina regen macro

Lets try to help you in a different way…

Is copying from the tutorial helping you at all in understanding what it is your code is doing?

Could you summarize what it does, how it does it, and come up with a reason as to why it is failing?

Can current stamina ever be greater than max stamina?

Why is stamina ever even allowed to go negative?

There is quite a lot of BPs there but…

In Refresh Stamina Regeneration, the StaminaRegenerationLooper update - can you add one Print String node there to test it out?

I’m always suspicious of timelines :wink: Check if it is looping correctly and if it starts and stops when needed.

P.S.
This is quite an elaborate setup for the simple thing you are trying to do but it is a critic to the tutorial, which I did not watch.

Hey, sorry for the late reply, @magumb0s!

I actually did a report on this stamina system back in the day for an applied maths course, so I’m able to follow this logic pretty easily! The Soulsborne stamina system is not your typical one so I see why you’d need all the extra parts.

I think your problem lies here, in the input. This is ONLY running the Completed line once, when you let go of the button. If you let go of the button before a montage completes it returns “True” and then it never sets the ENUM back to “None”, keeping you from increasing speed again AND preventing stamina recovery. Try connecting the “True” line to the Set Enum node as well and test it.


Try to scroll to the right with those errors so we can actually locate them. :slight_smile: You can click on any of the errors where there’s a magnifying glass and it will take you right to the issue at hand!

Because in the Soulsborne system of stamina if you have even 1 point of stamina you can execute any stamina consuming move, but because of the delayed recovery it really simulates struggling and being winded quite well. Though personally, I’d just clamp it before setting instead of setting it to 0 directly after.

Thanks so much for getting back and no worries at all!

Here’s the rest of the error message but maybe worth noting that I don’t get the error if I switch the Anim Instance target mesh out for the First Person Mesh. Doing that though, I still have the problem of stamina not regenerating.

So it’s a “Get AnimInstance” function needed for a specific Branch node on the player character’s Event Graph. Which means unless you have another one somewhere, this is the problem right here. Maybe just go around this node, bypass that branch completely for now.

Because of this error it couldn’t get through that branch, therefore it couldn’t set the Enum to none(which would allow you to sprint again), and it couldn’t start the regeneration macro!

Alright! I’ve tried bypassing that branch as well as connecting both true and false at the same time. Still no luck.

Going back to how it was originally set, with just False connected, I added a Print String to the end of the Handle Stamina Regen macro. That’s printing when I let go of sprint.

I then followed the bouncing ball to the Refresh Stamina Regeneration event and added a Print String in between the looper and the Stamina Regen Tick. That’s also printing, over and over again when I let go of sprint. As expected.

So am I right in thinking this has something to do with the Stamina Regen Tick?

1 Like

I figured it out!

Further to my previous reply, it was indeed the Stamina Regen Tick

I had the False branch connected to Set Stamina Regen. It should be Set Current Stamina.

Again, I added a print string to the False branch, confirmed it was printing and that was the smoking gun.

My gosh. What a ride. But I think I have a pretty good grasp on everything this system is doing now as a result.

Thank you so much for being so patient and working through it with me.

1 Like

Next time, remeber that Is Valid is a thing :wink:

Probably worth for Op to implement that.

Just check if animinstance is valid before perofmring whatever else.