The referenced script on this Behaviour is missing!

var health1 : Texture2D; //one lives left
var health2 : Texture2D; //two lives left
var health3 : Texture2D; //full health

static var LIVES = 3;

function Update () 
        case 3:
            guiTexture.texture = health3;

        case 2:
            guiTexture.texture = health2;

        case 1:
            guiTexture.texture = health1;

        case 0:
            //gameover script here

var speed = 3.0;
var rotateSpeed = 3.0;
var bullitPrefab: Transform;
private var dead = false;

function OnControllerColliderHit(hit : ControllerColliderHit)
    if(hit.gameObject.tag == "fallout")
        dead = true;
        //substract life here
        HealthControl.LIVES -=1;

function Update ()
    var controller : CharacterController = GetComponent(CharacterController);
    transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
    var forward = transform.TransformDirection(Vector3.forward);
    var curSpeed = speed * Input.GetAxis ("Vertical");
    controller.SimpleMove(forward * curSpeed);

        var bullit = Instantiate(bullitPrefab, GameObject.Find("spawnPoint").transform.position, Quaternion.identity);
        bullit.rigidbody.AddForce(transform.forward * 2000);

function LateUpdate()
        transform.position = Vector3(0,4,0);
        gameObject.Find("Main Camera").transform.position = Vector3(0,4,-10);
        dead = false;

@script RequireComponent(CharacterController)

After I made this scripts, I get the "The referenced script on this Behaviour is missing! " Warning...

more ▼

asked Apr 29, 2011 at 08:18 PM

Kantenstain gravatar image

16 1 2 2

Is the script actually connected to a game object? Sometimes unity seems to lose the connections.

Apr 29, 2011 at 08:26 PM LKIM
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

I don't think that this have anything to do with the content of this script. This error occurs when you have a script attached to a gameobject and you deleted, moved or renamed it outside of unity. Unity can't find the related script for the MonoBehaviour component.

If you want to rename or move a script do it always in Unity. To solve your error, just find the component that references this missing script and drag the right script onto the component.

more ▼

answered Apr 29, 2011 at 09:17 PM

Bunny83 gravatar image

73k 23 90 315

(comments are locked)
10|3000 characters needed characters left

I had this issue recently. For me the message appears when I run the game and it will only highlight the GameObject with the missing script if it is in the current scene.

I was able to load different scenes after running it and I was able to find the offending GameObjects.

more ▼

answered Sep 14, 2011 at 10:30 AM

Bovine gravatar image

1.9k 81 66 109

For anyone caught out by this. pause the game play when the warning appears. highlight the warning in your console. look in your hierarchy - Unity does highlight the problem item in the hierarchy once you click on the warning in the console. you'll then see the script is simply missing. As Bov says it has to be the current scene, so pause the game is scenes are changing quickly.

Apr 17, 2013 at 05:17 PM Fattie

Thanks. I've tried pausing and highlighting the error, but it does not work for me. Any other ideas?

Jul 31, 2013 at 01:30 AM ShinyTaco

It is caused by a missing behaviour. Clicking the error while the object is alive is the only way to find it besides manually checking everything. Are you dynamically destroying objects? It might only exist for long enough to throw the error. Enable the 'Pause on error' option in the console window (control+shift+C) and the game should stop before the object disappers. If not, you'll have to check your instantiable objects and see which one is missing a script.

Jul 31, 2013 at 02:22 AM Loius
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Apr 29, 2011 at 08:18 PM

Seen: 11481 times

Last Updated: Jul 31, 2013 at 02:22 AM