- Home /
Question is off-topic or not relevant
completely lost noob
So I went back to finish the tutorial I started the other day ( and have been having great difficulty with..) and when I loaded it up, the entire scene was missing, all I had left was the things in the assets directory. When I remade the scene and tried to attach the scripts, it just plain isnt working. No idea whats wrong, I get the following error:
NullReferenceException: Object reference not set to an instance of an object Movement.Update () (at Assets/Scripts/Movement.js:16)
And when I click play the capsule I have attached the movement script to doesn't move. Here are the scripts:
 #pragma strict
 
 var firstStepTex: Texture; 
 
 private var firstStepTaken:boolean;
 private var edgeMargin: float;
 
 function Start()
 {
     edgeMargin = Screen.width * .05;
 }
 
 function playerMoved()
 {
     if(!firstStepTaken)
     {
         unlockAchievement(firstStepTex);
         firstStepTaken = true; 
     }
 }
 
 function unlockAchievement(achievementTex:Texture)
 {
     var go:GameObject = new GameObject("Achievement Object");
     go.transform.position = Vector3(0,0,0);
     go.transform.localScale = Vector3(0,0,0);
     var guitex: GUITexture = go.AddComponent(GUITexture) as GUITexture;
     guitex.texture = achievementTex;
     guitex.pixelInset.width = achievementTex.width;
     guitex.pixelInset.width = achievementTex.height;
     guitex.pixelInset.x = Screen.width - achievementTex.width - edgeMargin;
     guitex.pixelInset.y = Screen.height - achievementTex.height - edgeMargin;
 }
 
 #pragma strict
 
 var achievementManagerScript: AchievementManagerScript; 
 var speed: int = 5;
 private var cc: CharacterController;
 
 function Start ()
 {
     cc = GetComponent(CharacterController);
 }
 
 function Update () 
 {
     if(Input.GetAxis("Horizontal") || Input.GetAxis("Vertical"))
     {
         achievementManagerScript.playerMoved();
     }
     
     cc.Move(-Vector3(Input.GetAxis("Horizontal") * speed * Time.deltaTime, 0,
     Input.GetAxis("Vertical") * speed * Time.deltaTime));
     
 }
 
 function OnTriggerEnter(col: Collider)
 {
     if(col.gameObject.tag == "Coins")
     {
         Destroy(col.gameObject);
     }
 }
Here is a link to the tutorial:
http://cgcookie.com/unity/2011/12/16/creating-an-achievement-system/
Any help to get this tutorial finish is greatly appreciated. Definitely not going to plan so far..
Answer by PAEvenson · Dec 18, 2012 at 03:51 PM
my guess is you didnt assign the achievementManagerScript in the inspector.
Follow this Question
Related Questions
error with footsteps script 1 Answer
Switch platform broke my scripts! 4 Answers
IsFinite(outDistanceForShort) error message 1 Answer
Compilation failed because the compiler couldn't be executed. 1 Answer
How to solve a Unity fatal error? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                