示例#1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("MachineOfPlayer"))

        {
            MainMachine machine = collision.gameObject.GetComponent <MainMachine>();
            machine.AddHealth(damage);
        }

        if (collision.gameObject.CompareTag("Enemy") || collision.gameObject.CompareTag("Player"))

        {
            MainCharacter character = collision.gameObject.GetComponent <MainCharacter>();
            character.AddHealth(damage);
        }

        Destroy(gameObject);
    }
示例#2
0
 private void Start()
 {
     player  = FindObjectOfType <Player>();
     machine = GetComponentInParent <MainMachine>();
 }