CrowdControllable.addStun C# (CSharp) Method

addStun() public method

public addStun ( float duration ) : void
duration float
return void
    public void addStun(float duration)
    {
        if (canStun == true)
        {
            Effect newStun = new Effect(0, duration);
            stuns.Add(newStun);
            isStunned = true;
            //The floating text should be replaced by a better graphical representation
            floatText.GetComponent<TextMesh>().text = "Stunned!";
            Instantiate(floatText, effectPosition, Quaternion.identity);
        }
    }

Usage Example

 void OnTriggerEnter(Collider col)
 {
     if(col.gameObject.tag == "Player")
     {
         crowdControllable = col.GetComponent<CrowdControllable>();
         crowdControllable.addStun(2);
         Destroy(gameObject);
     }
 }