Making a Unity Game NEED HELP RRS feed

  • Question

  • I have two errors, CS0103, and CS0116. I am making a game and this is my code:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class PumpkinScript : MonoBehaviour {
        void Update () {
            if (transform.position.y < -3f) {


    #pragma warning disable CS0116 // A namespace cannot directly contain members such as fields or methods
    private void OnCollisionEnter(Collision target) {
    #pragma warning restore CS0116 // A namespace cannot directly contain members such as fields or methods
            if (target.gameObject.tag == "Golem")
            Destroy (target.gameObject);
            Time.timeScale = 0f;

    • Moved by Stanly Fan Tuesday, March 6, 2018 1:20 AM
    Monday, March 5, 2018 10:19 PM

All replies

  • Hi kevparang,

    Thank you for posting here.

    Please install UnityEngine5 in your Manage NuGet Package first.

    According to your code, please put the OnCollisionEnter method inside the PumkinScript class.

    For more information about CS0103 and CS0116, you could refer to the MSDN document.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Tuesday, March 6, 2018 1:32 AM
  • Hello, what is incorrect is that you have a class (assuming it's within a namespace as the last closing bracket has no match and most likely the closer for the namespace. So, you need to place the code in the rectangle into a method within the class PunkinScript, same as you have code in Update method.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, March 6, 2018 1:33 AM