Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

Mark Benitez

FPC Move, Sprint, and Stamina system

Recommended Posts

Here is a simple charecter movement script with sprint and stamina, take note it is setup so you can have stamina potions and add difficulty to the game

 

if you want to know how to set up this script check out the video at the bottom of this post

Please login or register to see this code.

Please login or register to see this link.

Edited by NightmareGames

Share this post


Link to post
Share on other sites

Two problems i found:

1.Update cannot be a coroutine (WaitForSeconds)

2.You will loose stamina if you're not even walking.

Share this post


Link to post
Share on other sites

To tell you the truth, the script comments aren't really helpful...

 

Here's what I mean:

Please login or register to see this code.

And why would you need a "stamina" potion in order to run again?

Share this post


Link to post
Share on other sites
Please login or register to see this quote. That's for the game in the tutorial series and how can they be anymore help full?

And there should not be any problems as it works perfect for, @themars2011 you can sprint until your stamina runs out

Share this post


Link to post
Share on other sites
Please login or register to see this quote.

 

Nono, i mean, you'll loose stamina if youre even not walking or running

Share this post


Link to post
Share on other sites
Please login or register to see this quote. Oh only if your holding down shift right? I'll have to see how to fix that, but do the comments help?

Share this post


Link to post
Share on other sites

I know, I forgot to not have sideways and backwards sprint but thanks later today I will update the script

Share this post


Link to post
Share on other sites
Please login or register to see this quote.

 

I don't think you can sprint backwards otherwise you will trip and fall (not recommended when in a fight). Sideways is a little hard but possible, chose not to add it in my game anyway.

Share this post


Link to post
Share on other sites
Please login or register to see this quote.

But still, in games you don't see people sprinting backwards that often.

Share this post


Link to post
Share on other sites

Subtracting stamina just by input and stamina greater than 0 wont fix it. Then it would decrease the stamina when shift was held even if you are not moving. Instead decrease stamina if your velocity is greater than walk speed. That would make it a little more practical.

Share this post


Link to post
Share on other sites

I don't think you get it mars, if you hold those inputs and you have an object in the way, say a wall or car, it will subtract even though you are not moving. It's more practical to subtract based on velocity than input because it means you are actually traveling somewhere for the energy to be subtracted instead of not moving and losing energy just because you have your fingers on the keys. Even cod uses this method by by saying if inputs are held and velocity is greater than the 0.5 or 1, then subtract. IE, use velocity because it is more practical.

Share this post


Link to post
Share on other sites

I make sure the velocity of the controller is higher than the sprint speed and check if it's grounded also.

Share this post


Link to post
Share on other sites

Me too my new ones beast lol I didn't even read the script so I didn't notice that was no checking is grounded. Looks like the guy that made that tut is missing quite a bit. And using redundant methods like stamina += 1 * Time.deltaTime. 1 should either be placed in a variable for easy manipulation or removed stamina += Time.deltaTime is the exact same thing

Share this post


Link to post
Share on other sites
Please login or register to see this quote.

yes i know but i dont need it because in my game there is no jumping and right now everything so far looks ok and dosent look like ill need to rewrite

Share this post


Link to post
Share on other sites

Hello, I really have no experience speaking English but try to modify the Script to work on my CharacterControls I do not know if it works for you :)

 

Please login or register to see this quote. Please login or register to see this code.

 

Edited by Sebastianmite

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×