Void Can't Be Used In This Context

Please Help Me. I have Multiple Collider Triggers but I don’t know how to put it in one code. Please help me. I don’t know how to explain it. Here’s the code and I got Void can’t be used in this context. The Void Trigger enter line

using UnityEngine;

namespace Vuforia
{
    public class Spawn : MonoBehaviour,
    ITrackableEventHandler

    {

      
        private TrackableBehaviour mTrackableBehaviour;
        public GameObject Monster;                // The enemy prefab to be spawned.

        public Vector3 Zone1V;
        public Vector3 Zone2V;
        public Vector3 Zone3V;
        public Vector3 Zone4V;
        public Vector3 Zone5V;

        public Collider Zone1;
        public Collider Zone2;
        public Collider Zone3;
        public Collider Zone4;
        public Collider Zone5;
        GameObject SpawnedM;


        void Start()
        {

            mTrackableBehaviour = GetComponent<TrackableBehaviour>();
            if (mTrackableBehaviour)
            {
                mTrackableBehaviour.RegisterTrackableEventHandler (this);
            }


          
        }
        public void OnTrackableStateChanged(
            TrackableBehaviour.Status previousStatus,
            TrackableBehaviour.Status newStatus)

        {
            if (newStatus == TrackableBehaviour.Status.DETECTED ||
                newStatus == TrackableBehaviour.Status.TRACKED ||
                newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
            {
                 void OnTriggerEnter(Collider.other)
                {

                    if(other.transform.name == "MZ1T")
                    {
                        Debug.Log("Monster In Zone 1");
                    }
                    else
                    {
                        SpawnedM = Instantiate (Monster,Zone1V,Quaternion.identity)as GameObject;
                    }
                }
            }



        }
}



          


      
}

The function OnTriggerEnter has to be declared as public in the global scope.

//...
public class Spawn : MonoBehaviour, ITrackableEventHandler
{
   
    void Start()
    {
        //..
    }
   
    public void OnTrackableStateChanged()
    {
        //..
    }
   
    public void OnTriggerEnter(Collider other)
    {
        //...
    }
   
}

actually it can be declared private or protected as well, they problem is you have to declare it in the class. not mid way through a other method.

Im using Vuforia and When the camera detects the object I want it to find if an external trigger and see if its true or false. Please help me. The method doesn’t work.

Ugh, poorly formatted code… makes it so hard to read.

Cleaned up and commented:

using UnityEngine;

namespace Vuforia
{
    public class Spawn : MonoBehaviour, ITrackableEventHandler
    {

        private TrackableBehaviour mTrackableBehaviour;
        public GameObject Monster;                // The enemy prefab to be spawned.

        public Vector3 Zone1V;
        public Vector3 Zone2V;
        public Vector3 Zone3V;
        public Vector3 Zone4V;
        public Vector3 Zone5V;

        public Collider Zone1;
        public Collider Zone2;
        public Collider Zone3;
        public Collider Zone4;
        public Collider Zone5;
        GameObject SpawnedM;

        void Start()
        {
            mTrackableBehaviour = GetComponent<TrackableBehaviour>();
            if (mTrackableBehaviour)
            {
                mTrackableBehaviour.RegisterTrackableEventHandler (this);
            }
        }
      
        public void OnTrackableStateChanged(
            TrackableBehaviour.Status previousStatus,
            TrackableBehaviour.Status newStatus)
        {
            if (newStatus == TrackableBehaviour.Status.DETECTED ||
                newStatus == TrackableBehaviour.Status.TRACKED ||
                newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
            {
                //NO - this is a method declaration, you can't put that inside another method
                /*
                void OnTriggerEnter(Collider.other)
                {
                    if(other.transform.name == "MZ1T")
                    {
                        Debug.Log("Monster In Zone 1");
                    }
                    else
                    {
                        SpawnedM = Instantiate (Monster,Zone1V,Quaternion.identity)as GameObject;
                    }
                }
                */
            }

        }
    }
}

See that section of code I commented out.

Yeah, that’s not allowed there. It won’t compile.

A method must be defined within the body of the class, not inside a method.

To be honest, I don’t even know what you’re even attempting to do with this code. From the looks of your problem, you do NOT know how to program.

What are you attempting to accomplish?

And what is this Vuforia you speak of?

Vuforia is an arguemented reality program/extension used in unity and used for augmented reality. And I was trying to see if there are other alternatives for my object spawn here is the full code.

using UnityEngine;

namespace Vuforia
{
    public class Spawn : MonoBehaviour,
    ITrackableEventHandler

    {

       
        private TrackableBehaviour mTrackableBehaviour;
        public GameObject Monster;                // The enemy prefab to be spawned.

        public Vector3 Zone1V;
        public Vector3 Zone2V;
        public Vector3 Zone3V;
        public Vector3 Zone4V;
        public Vector3 Zone5V;

        public Collider Zone1;
        public Collider Zone2;
        public Collider Zone3;
        public Collider Zone4;
        public Collider Zone5;
        GameObject SpawnedM;


        void Start()
        {
            mTrackableBehaviour = GetComponent<TrackableBehaviour>();
            if (mTrackableBehaviour)
            {
                mTrackableBehaviour.RegisterTrackableEventHandler (this);

            }
        }
        public void OnTrackableStateChanged(
            TrackableBehaviour.Status previousStatus,
            TrackableBehaviour.Status newStatus)

        {
        if (newStatus == TrackableBehaviour.Status.DETECTED ||
            newStatus == TrackableBehaviour.Status.TRACKED ||
            newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
                {
                    SpawnedM = Instantiate (Monster, Zone1V, Quaternion.identity) as GameObject;
                    Debug.Log ("Monster Summoned");
                }
            else
                {
                    Destroy(SpawnedM);
                    Debug.Log ("Monster Destroyed");
                }
            }
        }
    }

All I want is If the Trackable Behavior is detected I want a object to be spawned in another spot if an object is in the intended spot. And I was thinking to use colliders as a reference as to know if a object is in the spot or not.

Will anyone else help me

You need to learn the basics. You’ve already been shown how to properly instantiate objects in the other thread you’ve posted.

I’m familiar with the vuforia sdk, what you’re asking for shouldn’t be too difficult, but I doubt anyone is going to be inclined to write your entire program for you.

Learn C#, learn unity and then come back. The forums will be much more useful and pleasant for you when you have a firm grasp of the basics.