Quantcast
Channel: Questions in topic: "javascript"
Viewing all articles
Browse latest Browse all 68

Ramp Hp function by speed

$
0
0
Hello. I call this function to roll the hp down when the character is hit with damage, or ramp it up when given food or a potion, instead of just saying hp -= x; function HpRoller(amt : float, roll : int){ while(amt >0){ amt -= 1 *Time.deltaTime; Hp += roll * Time.deltaTime; yield;} } for damage for example, i would call it with a negative number, so PlayerJs.HpRoller(200, -1); and for potions PlayerJs.HpRoller(50, 1); I would just like for it go faster then 1 per second. How do I correctly multiply it by Time.deltaTime to ramp faster? I tried this but realized it would not accurately ramp Hp function HpRoller(amt : float, roll : int){ while(amt >0){ amt -= 1 * (15*Time.deltaTime); Hp += roll * (15*Time.deltaTime); yield;} }

Viewing all articles
Browse latest Browse all 68

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>