Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Bashamock · Dec 11, 2015 at 01:57 PM · objectinstance

Object reference not set to an instance of an object.

I keep getting this error whenever I try opening my Unity project in Visual Studios when building it as windows 10 universal app. Here is my code using UnityEngine; using System.Collections;

public class character_movement : MonoBehaviour {

 public float moveSpeed;
 public float jumpHeight;


 public Transform groundCheck;
 public float groundCheckRadius;
 public LayerMask whatIsGround;
 private bool grounded;

 public Transform wallCheckLeft;
 public Transform wallCheckRight;

 public float wallCheckRadiusLeft;
 public float wallCheckRadiusRight;

 public LayerMask whatIsWall;

 private bool wallSliding;
 private bool doubleJump;

 

 void Start () {

 }// start

 void FixedUpdate(){
     grounded = Physics2D.OverlapCircle (groundCheck.position, groundCheckRadius, whatIsGround);
     wallSliding = Physics2D.OverlapCircle (wallCheckLeft.position, wallCheckRadiusLeft, whatIsWall); //check wall left hand
     wallSliding = Physics2D.OverlapCircle (wallCheckRight.position, wallCheckRadiusRight, whatIsWall); //check wall right hand

 }//Fixed Update




 void Update () {

     if (grounded) {
         doubleJump = false;
     }

     if(Input.GetKeyDown(KeyCode.Space)&& grounded){
         GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jumpHeight);
     }// if jump


     if (wallSliding) {
         doubleJump = false;
         GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.y, -1);
     }

     if(Input.GetKeyDown(KeyCode.Space)&& wallSliding){
         GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jumpHeight);
     }// if jump


     if (Input.GetKeyDown (KeyCode.Space) && !doubleJump && !grounded) {
         GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jumpHeight);
         doubleJump = true;
     }//if  double jump


     if(Input.GetKey(KeyCode.D)){
         GetComponent<Rigidbody2D>().velocity = new Vector2(moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
     }// if press D
     
     if(Input.GetKey(KeyCode.A)){
         GetComponent<Rigidbody2D>().velocity = new Vector2(-moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
     }// if press A

 }// update

} //main

using UnityEngine; using System.Collections;

public class Checkpoint : MonoBehaviour {

 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
 
 }

}

using UnityEngine; using System.Collections;

public class level_manager : MonoBehaviour {

 public GameObject currentCheckpoint;
 private character_movement player;

 // Use this for initialization
 void Start () {
     player = FindObjectOfType<character_movement> ();
 }
 
 // Update is called once per frame
 void Update () {
 
 }

 public void Respawn(){
     Debug.Log("Player Respawn");
     player.transform.position = currentCheckpoint.transform.position;
 }//Respawn

}

using UnityEngine; using System.Collections;

public class player_death : MonoBehaviour {

 public level_manager levelManager;

 void OnTriggerEnter2D(Collider2D other){
     if (other.name == "Player") {
         levelManager.Respawn();
     }//if player
 }//Trigger

}

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image P3JX · Dec 16, 2015 at 10:25 AM 0
Share

Create new simple project and check error exist there too.

avatar image wibble82 · Dec 16, 2015 at 10:40 AM 0
Share

It should tell you what line of code is causing the issue as part of the error - could you provide the error and all the other information that comes with it.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

InstanceID Changing When Game Start 1 Answer

Something I don't fully understand about C# - the ref modifier 2 Answers

How to instantiate object onto other object from script 1 Answer

object not set to instance? 1 Answer

Script decides not to run anymore 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges