Hi, i need help with my script. I have this error: Type DoorScript' does not contain a definition for
index’ and no extension method index' of type
DoorScript’ could be found (are you missing a using directive or an assembly reference?). I don’t know how to fix it. I search this solution on google, but it doesn’t match any solutions for this. Here’s the script:
using UnityEngine;
using System.Collections;
public class interactScript : MonoBehaviour {
public float interactDistance = 5f;
public AudioClip keyPickup;
void Update ()
{
if(Input.GetKeyDown(KeyCode.Mouse0))
{
Ray ray = new Ray(transform.position, transform.forward);
RaycastHit hit;
if(Physics.Raycast(ray, out hit, interactDistance))
{
if(hit.collider.CompareTag("Door"))
{
DoorScript doorScript = hit.collider.transform.parent.GetComponent<DoorScript>();
if(doorScript == null) return;
if(doorScript.name == "hinge")
{
doorScript.ChangeDoorState();
return;
}
if(Inventory.keys[doorScript.index] == true)
{
doorScript.ChangeDoorState();
}
}
else if(hit.collider.CompareTag("Key"))
{
Inventory.keys[hit.collider.GetComponent<Key>().index] = true;
AudioSource.PlayClipAtPoint(keyPickup, hit.collider.transform.position);
Destroy(hit.collider.gameObject);
}
else if(hit.collider.CompareTag("NextLeveldoor"))
{
Application.LoadLevel(1);
}
}
}
}
}
Please help me with this error quickly!!!