示例#1
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        Player_Controller1 player = other.gameObject.GetComponent <Player_Controller1>();

        if (player != null)
        {
            player.ChangeHealth(-1);
        }
    }
示例#2
0
    private void OnTriggerStay2D(Collider2D other)
    {
        Debug.Log(other);

        Player_Controller1 controller = other.GetComponent <Player_Controller1>();

        if (controller != null)
        {
            controller.ChangeHealth(-15);
        }
    }
    void Start()
    {
        Ruby   = GameObject.Find("Ruby").GetComponent <Transform>();
        RubyRB = GameObject.Find("Ruby").GetComponent <Rigidbody2D>();
        RUBY   = GameObject.Find("Ruby").GetComponent <Player_Controller1>();

        Cam = GetComponent <Camera>();

        for (int i = 0; i <= 90; i++)
        {
            Debug.Log("i = " + i + "    Cos = " + Mathf.Cos(i));
        }
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log(other);

        Player_Controller1 controller = other.GetComponent <Player_Controller1>();

        if (controller != null)
        {
            if (controller.HealthPoints < controller.MaxHP)
            {
                controller.ChangeHealth(35);

                Destroy(gameObject);
            }
        }
    }