Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Jun 23, 2017 at 03:57 AM by hexagonius for the following reason:

https://docs.unity3d.com/Manual/NullReferenceException.html

avatar image
2
Question by Countothree · Apr 21, 2015 at 12:53 PM · roll a ballnullreference

Nullreferenceexception on roll a ball project

I am incredibly new to unity, just downloaded it this morning and jumped right in with the roll a ball project. I'm starting to get the impression this was the wrong place to start. I have followed the tutorial step by step and copied his code word for word but am still getting this error message:

NullReferenceException: Object reference not set to an instance of an object PlayerController.FixedUpdate () (at Assets/scripts/PlayerController.cs:22)

Here is the script:

using UnityEngine; using System.Collections;

public class PlayerController : MonoBehaviour {

 public float speed;

 private Rigidbody rb;
 
 void start ()
 {
     rb = GetComponent<Rigidbody>();
 }

 void FixedUpdate ()
 {
     float moveHorizontal = Input.GetAxis ("Horizontal");
     float moveVertical = Input.GetAxis ("Vertical");
     
     Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
     
     rb.AddForce (movement * speed);
 }

}

Now, im gonna take myself off and learn a bit about scripting before even coming back to this thing, but for the sake of my sanity, can someone please tell me where i went wrong?

Comment
Add comment
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

1 Reply

  • Sort: 
avatar image
13
Best Answer

Answer by dreinzy · Apr 24, 2015 at 07:08 AM

Your void **S**tart isn't capitalised...

Comment
Add comment · Show 5 · Share
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 Countothree · Apr 24, 2015 at 11:01 AM 1
Share

I can't believe i missed something so simple, i went over it about 40 times as well. Thank you for spotting it!

avatar image Pigny · Nov 09, 2015 at 07:11 AM 0
Share

I had this same problem! I was quite frustrated, but wow, that simple capital S huh... Godly answer!

avatar image nipun.airfoce · Feb 01, 2016 at 09:57 PM 0
Share

Thanx! I dint even notice that while going through the code again and again :D

avatar image nabtron nipun.airfoce · May 16, 2016 at 11:57 AM 0
Share

you should use code comparison with the demo one

avatar image nabtron · May 16, 2016 at 11:56 AM 0
Share

you're awesome man! you prevented me from giving up unity! :D

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Null Reference Exception ? :/ 1 Answer

AddForce relative to camera rotation 1 Answer

Weird bug. Roll a ball project 0 Answers

what is wrong with my script?!?!?! 1 Answer

How to create a rolling sound that only plays when object is moving? 2 Answers


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