Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Error CS1061

$
0
0
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(); 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().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!!!

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>