コード例 #1
0
 private void KillOnClick()
 {
     RaycastHit2D[] hits =
         Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
     foreach (var hit in hits)
     {
         GoblinDead goblin = hit.collider.GetComponent <GoblinDead>();
         if (goblin != null)
         {
             Debug.Log("Killing " + goblin.gameObject.name);
             goblin.OnDead();
         }
     }
 }
コード例 #2
0
 void Update()
 {
     if (Input.GetKey(KeyCode.LeftControl) && Input.GetMouseButtonDown(0))
     {
         RaycastHit2D[] hits =
             Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
         foreach (var hit in hits)
         {
             GoblinDead goblin = hit.collider.GetComponent <GoblinDead>();
             if (goblin != null)
             {
                 Debug.Log("Killing " + goblin.gameObject.name);
                 //  goblin.ForcefullKill();
             }
         }
     }
 }