Beispiel #1
0
 void OnCollisionEnter(Collision col)
 {
     //print("collision player : " + col.gameObject.name + " player who spawned is : " + gameObject.name );
     if (col.gameObject.GetComponent<UniversalHealth>() && col.gameObject != playerShooting) {
         //Damage whatever collided with the projectile
         GameObject collidedObject = col.gameObject;
         health = collidedObject.GetComponent<UniversalHealth>();
         health.damagePlayer (projectileDamage);
         Destroy (gameObject, 0.5f);
     }
 }
Beispiel #2
0
    void OnCollisionEnter(Collision col)
    {
        GameObject collidedObject = col.gameObject;

        if (collidedObject.name == "player1" || collidedObject.name == "player2")
        {
            //Damage whatever collided with the projectile
            health = collidedObject.GetComponent <UniversalHealth>();
            health.damagePlayer(projectileDamage);
        }
        Destroy(gameObject);
    }
Beispiel #3
0
    void OnCollisionEnter(Collision col)
    {
        GameObject collidedObject = col.gameObject;

        if (collidedObject.name == "player1" || collidedObject.name == "player2")
        {
            //Damage whatever collided with the projectile
            health = collidedObject.GetComponent<UniversalHealth>();
            health.damagePlayer(projectileDamage);
        }
        Destroy(gameObject);
    }
Beispiel #4
0
 void OnCollisionEnter(Collision col)
 {
     //print("collision player : " + col.gameObject.name + " player who spawned is : " + gameObject.name );
     if (col.gameObject.GetComponent <UniversalHealth>() && col.gameObject != playerShooting)
     {
         //Damage whatever collided with the projectile
         GameObject collidedObject = col.gameObject;
         health = collidedObject.GetComponent <UniversalHealth>();
         health.damagePlayer(projectileDamage);
         Destroy(gameObject, 0.5f);
     }
 }
Beispiel #5
0
    void OnCollisionEnter(Collision col)
    {
        //If you collided with the other player
        if (otherPlayer && col.gameObject.name == otherPlayer.name)
        {
            //Calculate and deal some damage to the player
            int damage = calculateDamage(col) * collisionAttackValue;
            health.damagePlayer(damage);

            //Play collision particle effect
            //particles.Play (); //this causes some errors
        }
    }
Beispiel #6
0
    //Behaviour functions
    void damagePlayer(GameObject player)
    {
        UniversalHealth health = player.GetComponent <UniversalHealth> ();

        health.damagePlayer(magnitude);
    }