Detection problems.

I’m pretty new to Unity and have been following a tutorial series. Everything has been going fine up until video 22 and I’m having a script problem. My question is two part.

Firstly when I initially downloaded Unity I must have installed Unity 5.5. It would seem that the tutorial I am following is using 5.0. Up till now everything worked fine but it would seem that there are some things different when it comes to scripting. First question, If I reinstall Unity with version 5.0 to be using the same version my tutorial is will I loose all my stuff up till now?

Second quest: If it is not possible to do that without loosing all my progress what could be changed about this script to make it work with Unity 5.5?

The error I am getting is on the detectionLayer part. When I scroll over it, it says (Argument3: cannot convert from ‘UnityEngine,LayerMask’ to ‘UnityEngine.Coliider[ ]’)

I have went over it plenty of time and I dont think I have anything different that what my tutorial has so I assume it is something about the scripting terminology changing in Unity 5.5? Here is the script I have. Thanks for any help, dorry to burden you guys.

[code=CSharp]using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

namespace Chapter1
{
    public class Enemy_Chase : MonoBehaviour
    {
        public LayerMask detectionLayer;
        private Transform myTransform;
        private NavMeshAgent myNavMeshAgent;
        private Collider[] hitColliders;
        private float checkRate;
        private float nextCheck;
        private float detectionRadius = 10;



        // Use this for initialization
        void Start()
        {
            SetInitialReferences();
        }

        // Update is called once per frame
        void Update()
        {
            CheckIfPlayerInRange();
        }

        void SetInitialReferences()
        {
            myTransform = transform;
            myNavMeshAgent = GetComponent<NavMeshAgent>();
            checkRate = Random.Range(0.8f, 1.2f);
        }

        void CheckIfPlayerInRange()
        {
            if (GetComponent<NavMeshAgent>().enabled == true)
            {
                nextCheck = Time.time + checkRate;

                hitColliders = Physics.OverlapSphereNonAlloc(myTransform.position, detectionRadius, detectionLayer);

                if (hitColliders.Length > 0)
                {
                    myNavMeshAgent.SetDestination(hitColliders[0].transform.position);
                }

            }

        }

    }
}

[/code]

You know, without knowing which tutorial series, or seeing the code, nobody can really help
the second qeustion is the same, some tutorials work, some don’t

This is the tutorial I’m following, opps I loaded wrong link first time.

If you go back to a previous version of Unity, your project might work or not. To be sure what would go broken exactly first make a backup of your project. Then just try to import your project in the old version of Unity, and see.

But it would be better to stick to the last version of Unity and try to adapt the code yourself. Anyhow, you will get warnings if you use something deprecated. So, you would just need to lookup in the documentation what’s the new way to do things.

Now the script you made please

Its in my original post isn’t it? I see it on my screen?

I’m pretty sure in the video he used Physics.OverlapSphere instead of the nonalloc version, because that has a collider[ ] argument, try changing it

Oh wow I feel like an idiot. When I first followed this tutorial I was getting the same error on the detection part and when I clicked the little light bulb it told me to write it that way, so I did. For what ever reason when I just switched it back, it works fine. So sorry to waste your time. I try really hard to figure these things out alone. Thanks again!