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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

CS0119 Error.

Discussion in 'Scripting' started by Reymus, Nov 10, 2015.

  1. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    Hi all. I'm getting the following error in my code. It's probably something silly, but I don't know.

    Assets/Scripts/DestroybyBoundary.cs(9,17): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected

    Here's the code in my DestroyByBoundary.cs

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class DestroybyBoundary : MonoBehaviour {
    5.  
    6.     void OnTriggerExit2D(Collider2D other)
    7.     {
    8.         Destroy(other.gameObject);
    9.         Startup().GroundCountSubtract();
    10.     }
    11. }
    This is supposed to call the GroundCountSubtract function in my Startup.cs, which is attached to the same object as the DestroyByBoundary.cs is.

    Where am I going wrong?
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,744
    Change that line to
    Code (csharp):
    1. GetComponent<Startup>().GroundCountSubtract();
     
  3. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    Thanks very much. I should have known that.