Month 2: Week 3
- Liston Harding
- Feb 20, 2017
- 1 min read
Weapon Fire Rate
In earlier builds of our game, the shoot function was a Co-routine that ran based on the fire rate value of a given weapon, this produced the desired effect but the timer didn't update unless the trigger was held; moreover, this prevented players from interacting with the weapon as intended.
Weapon Fire Rate: (FIX)
To fix the unintended behavior I created a float called m_lastShot, which stores the time of the previous shot. By adding the fire rate variable of a given weapon to the m_lastShot variable, I can check if that amount is greater than Unity's Time.time value and if it is, I'm able to fire my weapon and after doing so m_lastShot is set to the new current time. Now the timer updates outside of the Co-routine, fixing this issue.
Heal
Heal, Our newest ability allows the player to regenerate some health over a certain amount of time. Getting this to work required some reading as I created this particle system that would rotate around the player position while giving off this aura indicating that the player is currently being healed. Besides visual feedback, the workings under the hood involve a sphere surrounding the player, and that sphere is a trigger; moreover, using the function OnTriggerStay() I call the heal function of the HealthManager(handles the health of all actors) and this allows me to increase the health of a given actor by a small floating point number as long as they are within range. Were looking to allow this ability to heal friendly allies within range, currently only the player is being healed.
Commenti