예제 #1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("ground") || other.CompareTag("enemy"))
     {
         enemymove script = enemy.GetComponent <enemymove>();
         script.direction = 0;
     }
 }
    //for detecting collision with enemy game object and runs hurt function if in contact with the enemy
    void OnCollisionEnter2D(Collision2D collision)
    {
        enemymove badguy = collision.collider.GetComponent <enemymove>();

        if (badguy != null)
        {
            foreach (ContactPoint2D point in collision.contacts)
            {
                if (point.normal.y >= 0.9f)
                {
                    Vector2 velocity = rb.velocity;
                    velocity.y  = jumpf;
                    rb.velocity = velocity;
                    badguy.Hurt();
                }
                else
                {
                    Hurt();
                }
            }
        }
    }
예제 #3
0
 void Start()
 {
     enemymove.instance = this;
     hard = hard + scoremanager1.instance.getscore() / nando;
     //hard = 0.2f;
 }