Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

error CS0117: 'Physics' does not contain a definition for 'OverlapSphereAll'

Discussion in 'Scripting' started by emoney101skeleton, Aug 1, 2020.

  1. emoney101skeleton

    emoney101skeleton

    Joined:
    Jun 7, 2020
    Posts:
    12
    So I'm Following a Melee Attack Script Tutorial And I Ran Into This error CS0117 I Checked It Myself Idk If It Is a Spelling Error Or Thats The Problem, Any Help?

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class FPSFirstCombat : MonoBehaviour
    6. {
    7.  
    8.     public Animator animator;
    9.  
    10.     public Transform Attackpoint;
    11.     public float attackRange = 0.5f;
    12.     public LayerMask enemyLayers;
    13.  
    14.  
    15.     // Update is called once per frame
    16.     void Update()
    17.     {
    18.         if (Input.GetKeyDown(KeyCode.G))
    19.         {
    20.             Attack();
    21.         }
    22.     }
    23.  
    24.     void Attack()
    25.     {
    26.         animator.SetTrigger("Attack");
    27.  
    28.  
    29.         Collider[] hitEnemies = Physics.OverlapSphereAll(Attackpoint.position, attackRange, enemyLayers);
    30.  
    31.  
    32.         foreach(Collider enemy in hitEnemies)
    33.         {
    34.             Debug.Log("We hit " + enemy.name);
    35.         }
    36.     }
    37.  
    38.     void OnDrawGizmosSelected()
    39.     {
    40.         if (Attackpoint == null)
    41.             return;
    42.  
    43.         Gizmos.DrawWireSphere(Attackpoint.position, attackRange);
    44.     }
    45. }
    Any Help?,Thank You
     
  2. Yanne065

    Yanne065

    Joined:
    Feb 24, 2018
    Posts:
    175
    Code (CSharp):
    1. Collider[] hitEnemies = Physics.OverlapSphereAll(Attackpoint.position, attackRange, enemyLayers);
    2.  
    To
    Code (CSharp):
    1. Collider[] hitEnemies = Physics.OverlapSphere(Attackpoint.position, attackRange, enemyLayers);
    2.  
     
  3. emoney101skeleton

    emoney101skeleton

    Joined:
    Jun 7, 2020
    Posts:
    12
    Thank you, I never thought that