- Home /
The referenced script on this behavior is missing!
I've just began using unity, and I am doing the Space Shooter Project, I'm on Video 6 (moving the player), and I'm stuck. I'm programming movement for the Spaceship, and one of the scripts is missing. Here is a link of my screen. Any help is appreciated. I've tried copying code directly fromt he tutorial video's description, but it doesn't work.
I removed the missing script, and copied the done_player controller code into player controller, but it still does not work. I also found a page on the missing script, but I don't understand it. I also have code for done_player controller, it has something in it about $$anonymous$$onoBehavior.
using UnityEngine;
using System.Collections;
[System.Serializable]
public class Done_Boundary
{
public float x$$anonymous$$in, x$$anonymous$$ax, z$$anonymous$$in, z$$anonymous$$ax;
}
public class Done_PlayerController : $$anonymous$$onoBehaviour
{
public float speed;
public float tilt;
public Done_Boundary boundary;
public GameObject shot;
public Transform shotSpawn;
public float fireRate;
private float nextFire;
void Update ()
{
if (Input.GetButton("Fire1") && Time.time > nextFire)
{
nextFire = Time.time + fireRate;
Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
audio.Play ();
}
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rigidbody.velocity = movement * speed;
rigidbody.position = new Vector3
(
$$anonymous$$athf.Clamp (rigidbody.position.x, boundary.x$$anonymous$$in, boundary.x$$anonymous$$ax),
0.0f,
$$anonymous$$athf.Clamp (rigidbody.position.z, boundary.z$$anonymous$$in, boundary.z$$anonymous$$ax)
);
rigidbody.rotation = Quaternion.Euler (0.0f, 0.0f, rigidbody.velocity.x * -tilt);
}
}
Answer by jbecana · Mar 16, 2014 at 10:49 AM
I think player only needs one player controller script, and you have two, I guess the missing one, done_player controller is the one done by the instructor. Have you tried just to remove the missing script component or replace the player controller by the done player controller?
Looks like you have the same classes in two different scripts. $$anonymous$$ove out of the assets directory the one is not attached to anything. $$anonymous$$onobehaviour is a the base class for your script. Your script needs to extend $$anonymous$$onobehaviour so you can use the Start(), Update() methods... Take care when you change the name of the scripts files because objects that have them attached as components loose their connection.
Your answer
Follow this Question
Related Questions
Car movement script ? 1 Answer
Issues with C# script (using tutorial) 1 Answer
Movement doesnt work if I rotate my model 2 Answers
Smooth Camera Follow Script, Weird Movement... Please help! 1 Answer
Burg Zerg Arcade Tutorial Help 3 Answers