Beispiel #1
0
    public IEnumerator RespawnPlayerCo()
    {
        //generate death particle
        Instantiate(DeathParticle, Player2.transform.position, Player2.transform.rotation);
        //player .enabled = false
        Player2.SetActive(false);
        Player2.GetComponent <Renderer>().enabled = false;
        // gravity Reset
        StoreGravity = Player2.GetComponent <Rigidbody2D>().gravityScale;
        Player2.GetComponent <Rigidbody2D>().gravityScale = 0f;
        Player2.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
        // point penalty
        ScoreManager.AddPoints(-PointPenaltyOnDeath);
        HealthManager.AddPoints(-HealthSubtractOnDeath);
        // Debug message
        Debug.Log("Player Respawn");
        // Respawn Delay
        yield return(new WaitForSeconds(RespawnDelay));

        // Gravity Restore
        Player2.GetComponent <Rigidbody2D>().gravityScale = StoreGravity;
        // match Players transform position
        Player2.transform.position = CurrentCheckPoint.transform.position;
        //show player
        Player2.SetActive(true);
        Player2.GetComponent <Renderer> ().enabled = true;
        // Spawn particle
        Instantiate(RespawnParticle, CurrentCheckPoint.transform.position, CurrentCheckPoint.transform.rotation);
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.GetComponent <Rigidbody2D>() == null)
        {
            return;
        }

        HealthManager.AddPoints(PointsToAdd);

        Destroy(gameObject);
    }
 void OnTriggerEnter2D(Collider2D Other)
 {
     if (Other.GetComponent <Rigidbody2D> () == null)
     {
         return;
     }
     if (Other.name == "PC_Arc")
     {
         HealthManager.AddPoints(HealthToAdd);
     }
 }