#Trigger Fear Coroutine

1 messages · Page 1 of 1 (latest)

terse cypress
#

Hello

#

chat is moving fast today

#

I don't actually use coroutines for anything yet, so I'm not sure I can help with that, but there are alternate solutions.

restive wing
#

I'd like to hear your solution! :)

terse cypress
#

First off - I have some questions

#

let's say Player Sanity is 30 out of 100

#

or, enemy, was it

#

?

restive wing
#

The player has a sanity meter yes

terse cypress
#

alright

#

so the player enters a trigger
a coroutine starts
it makes it so that every second your player was inside the trigger, it added +1 to currentSanity

restive wing
#

Yes Thats what I would like but instead it adds 1 in a split second and gets to 100 under 1 second.

terse cypress
#

which is the error, yes

restive wing
#

yes

terse cypress
#

gainFearFunction()
this one loops until i == maxSanity
adding 0.01 to currentSanity each time
which doesn't really make sense to me

#

so I will for now presume that function to be "wrong" and must be replaced

#

I'll write out an example I think will work

restive wing
#

adding 0.01 was a test but I changed it back to adding 1.

restive wing
terse cypress
#

you're adding 1 x 100 times

#

that's why it goes up to that high

#

maybe just

#
yield return new WaitForSeconds(1);
vitalsController.currentSanity++;
yield return new WaitForSeconds(1);
#

try that

restive wing
#

inside the for loop right?

terse cypress
#

no, where you recognize the top and bottom lines

#

it replaces the gainFeatFunction()

#

might need these as well

#
vitalsController.UpdateUI();
vitalsController.UpdatePPFX();
restive wing
#

I putted it directly in the gainFear() Enmerator and it does add up 1 every 0.5 seconds now.

terse cypress
#

every half second?

restive wing
#

I can see it counting but it does not count every second. I'll probaly have to play around with the WaitForSeconds

terse cypress
#

other approach is a bit more code

restive wing
#

oh no the first one is working

#

I got it to work thanks!

terse cypress
#

alright, good stuff :)

#

Have a nice day o/