[Solved] 3DTutorialStart - Help on spaceship animation

Hi,

I am new to unity and just trying out the tutorial parts, and started on 3D Tutorial and went on no problem until i came to adding the shipAnimation. I dragged the shipAnimation to the spaceShip game object and added the script also. when i run the game, i get an error.

“MissingComponentException : There is no ‘Animation’ attached to the ‘spaceShip’ game object, but a script is trying to access it.”

Ill try to get the scrnshots if you guys still want to know more about it.

// LevelStatus: Master level state machine script.
var exitGateway: GameObject;
var levelGoal: GameObject;
var unlockedSound: AudioClip;
var levelCompleteSound: AudioClip;
var mainCamera: GameObject;
var unlockedCamera: GameObject;
var levelCompletedCamera: GameObject;
// This is where info like the number of items the player must collect in order to 
//complete the level lives.
var itemsNeeded: int = 20; // This is how many fuel canisters the player must collect.
private var playerLink: GameObject;
// Awake(): Called by Unity when the script has loaded.
// We use this function to initialise our link to the Lerpz GameObject.
function Awake()
{
 levelGoal.GetComponent(MeshCollider).isTrigger = false;
 playerLink = GameObject.Find("Player");
 if (!playerLink)
  Debug.Log("Could not get link to Lerpz");
 levelGoal.GetComponent(MeshCollider).isTrigger = false; // make very sure of this!
} 
function UnlockLevelExit()
{
 mainCamera.GetComponent(AudioListener).enabled = false;
 unlockedCamera.active = true;
 unlockedCamera.GetComponent(AudioListener).enabled = true;
 exitGateway.GetComponent(AudioSource).Stop();
 
 if (unlockedSound)
  {
   AudioSource.PlayClipAtPoint(unlockedSound,
   unlockedCamera.GetComponent(Transform).position, 2.0);
  }
 yield WaitForSeconds(1);
 exitGateway.active = false; // ... the fence goes down briefly...
 yield WaitForSeconds(0.2); //... pause for a fraction of a second...
 exitGateway.active = true; //... now the fence flashes back on again...
 yield WaitForSeconds(0.2); //... another brief pause before...
 exitGateway.active = false; //... the fence finally goes down forever!
 levelGoal.GetComponent(MeshCollider).isTrigger = true;
 yield WaitForSeconds(4); // give the player time to see the result.
 // swap the cameras back.
 unlockedCamera.active = false; // this lets the NearCamera get the screen all to itself.
 unlockedCamera.GetComponent(AudioListener).enabled = false;
 mainCamera.GetComponent(AudioListener).enabled = true;
}
function LevelCompleted()
{
 mainCamera.GetComponent(AudioListener).enabled = false;
 levelCompletedCamera.active = true;
 levelCompletedCamera.GetComponent(AudioListener).enabled = true;
 playerLink.GetComponent(ThirdPersonController).SendMessage("HidePlayer");
 playerLink.transform.position+=Vector3.up*500.0; // just move him 500 units
 
 if (levelCompleteSound)
 {
  AudioSource.PlayClipAtPoint(levelCompleteSound, levelGoal.transform.position, 
  2.0);
 }
 levelGoal.animation.Play();
 yield WaitForSeconds (levelGoal.animation.clip.length);
 Application.LoadLevel("GameOver"); //...just show the Game Over sequence.
}

There is no “spaceShip” game object in that script. There is a “levelGoal” object with a call for an animation on it. Are you supposed to drag the Spaceship object onto the Levelgoal game object?

Something seems very strange here…

We don’t hv too as per tutorial, the levelGoal checks for the mesh collider and isTriggered event, it comes to those functions without a problem. But only thing is the animation is not playing… But when i use play automatically option for the animation it works, but as soon as the game starts…

The tutorial says isTrigger needs to be turned off for the spaceShip

But when isTrigger option is off, i am not able to get past the CutScene2 and the char just stands there. But if the isTrigger option is on, the scene goes to the cutscenecamera2 and the player flies up 500 feet and the animation error comes…

the handlespaceshipcollision script

private var playerLink : ThirdPersonStatus;

Debug.Log("Inside Spaceship Handle Collision");

function OnTriggerEnter (col : Collider) 
{
	playerLink=col.GetComponent("ThirdPersonStatus");
	playerLink=col.GetComponent(ThirdPersonStatus);
	Debug.Log("Inside Function OnTriggerEnter");
 
	if (!playerLink) // not the player.
	{
	   Debug.Log("Not the Player");
	   return;
	}
	else
	{
	  Debug.Log("Level Completed Triggered");
	  playerLink.LevelCompleted();
	} 
}

function Update () {
}

Anyone who did run the 3D tutorial…? Help needed…


You need an Animation component on the ship object (menu: Component > Miscellaneous > Animation).

Isn’t my screen shot shows the animation component been already there…? I am sure my scrn shot shows the animation component on the spaceShip Game Object.

We’ll instead of selecting the spaceShip on the scene which has the script and animation component, I selected the spaceShip object on the asset (library) highlighted in light orange.

I just noticed that in the LevelStatus script and its solved. the tutorial was great everything worked out well…