I keep getting this UnityEngine.Collider[]' does not contain a definition for `Lenght'

Well, i cant figure this error, i tryed everything. Assets/Folders/Scripts/Enemy_Detection.cs(55,22): error CS1061: Type UnityEngine.Collider[ ]' does not contain a definition for Lenght’ and no extension method Lenght' of type UnityEngine.Collider[ ]’ could be found. Are you missing an assembly reference?

Code:

using UnityEngine;
using System.Collections;

namespace S3
{
public class Enemy_Detection : MonoBehaviour {

private Enemy_Master enemyMaster;
private Transform myTransform;
public Transform head;
public LayerMask playerLayer;
public LayerMask sightLayer;
private float checkRate;
private float nextCheck;
private float detectRadius = 80;
private RaycastHit hit;

void OnEnable()
{
  SetInitialReferences ();
  enemyMaster.EventEnemyDie += DisableThis;
}

void OnDisable()
{
  enemyMaster.EventEnemyDie -= DisableThis;
}

void Update()
{
  CarryOutDetection ();
}

void SetInitialReferences()
{
  enemyMaster = GetComponent<Enemy_Master> ();
  myTransform = transform;

  if (head == null)
  {
   head = myTransform;
  }

  checkRate = Random.Range (0.8f, 1.2f);
}

void CarryOutDetection()
{
  if(Time.time > nextCheck)
  {
   nextCheck = Time.time + checkRate;

    Collider[] colliders = Physics.OverlapSphere (myTransform.position, detectRadius, playerLayer);

    if (colliders.Lenght > 0) {
     foreach (Collider potentialTargetCollider in colliders) {
      if (potentialTargetCollider.CompareTag ("GameManager_References._playerTag")) {
       if (CanPotentialTargetBeSeen (potentialTargetCollider.transform)) {
        break;
       }
      }
     }
    }
    else
    {
       enemyMaster.CallEventEnemyLostTarget ();
   }
  }
}

bool CanPotentialTargetBeSeen(Transform potentialTarget)
{
  if (Physics.Linecast (head.position, potentialTarget.position, out hit, sightLayer))
   {
   if (hit.transform == potentialTarget)
    {
    enemyMaster.CallEventEnemySetNavTarget (potentialTarget);
    return true;
   } else {
    enemyMaster.CallEventEnemyLostTarget ();
    return false;
   }
  }
  else
  {
   enemyMaster.CallEventEnemyLostTarget ();
   return false;
  }
}

void DisableThis()
{
  this.enabled = false;
}
}
}
1 Like

Did you try Length instead? Those two misplaced letters on the end are critical.

Generous use of autocomplete helps with this.

5 Likes

What do you mean? I really dont know much about scripting. :slight_smile:

1 Like

What scripting environment are you using? MonoDevelop? VisualStudio? Notepad++?

1 Like

It has nothing to do with scripting. It has to do with knowing how to write “Length”.

Why’s @ArachnidAnimal liking every post in this thread?

1 Like

Lenght and Length are not the same thing.

Haha sorry i didnt saw this, i must be the most stupidest person in the world xD