Add controlled slow motion Functionality.

posted in: Weekly Progress | 0

Slow motion functionality is added to slow the game for some time , so it will be useful for the user to kill harmful animals .

Enabled Slow Motion icon is :

 

Disabled Slow Motion icon is :

code is :

 

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class SlowMotionGameController : MonoBehaviour
{
public float CoolDownTime;
private float _coolDownTimer;
private ButtonImageController _btnController;
void Start()
{
_coolDownTimer = CoolDownTime;
_btnController = GetComponent<ButtonImageController>();
}
void Update()
{
if ((_coolDownTimer -= Time.deltaTime) <= 0)
{
_btnController.SetPressedSprite();
LevelManager.Instance.SetSlowMotion(false);
}

}
public void ActivateSlowMotion()
{
_coolDownTimer = CoolDownTime;
_btnController.SetNormalSprite();
LevelManager.Instance.SetSlowMotion(true);

}
}

Leave a Reply