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 /
avatar image
0
Question by nickazoid · Apr 27, 2015 at 06:36 AM · instantiatetutorialroguelike

In the tutorial of the 2D Roguelike game, where is the player gameobject instantiated in the code?

The player character is not instantiated on any levels.

I tried changing between levels with and without enemies, but still not instantiated. When an enemy is instantiated in the level the following error message shows up:

NullReferenceException: Object reference not set to an instance of an object Enemy.Start () (at Assets/Scripts/Enemy.cs:14

This error message shows up as many times as there are enemies on the board.

I have gone through the tutorial videos from start to finish several times now, but I cannot find where the player is actually spawned into the level. What am I missing?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by another_kind · Apr 27, 2015 at 02:28 PM

In the beginning of part 8, he puts the player prefab in the hierarchy, I think it stays there from that point, which means the player doesn't have to be instantiated in the code.

Comment
Add comment · Show 2 · 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 nickazoid · Apr 28, 2015 at 04:49 AM 0
Share

Ah, I missed that. Thank you, but I still get the error message and my character won't move.

The character is animated, but doesn't react to pressing keys. I double checked the code component, correctly spelled, but still doesn't respond. I even copied the code from the completed script, but still the same error message.

avatar image WolfCamoedSheep · Apr 30, 2015 at 12:28 PM 0
Share

I'm having the same problem. The player doesn't react to keypresses. I tried using only completed scripts, yet I still got the same error message spammed continuesly.

NullReferenceException: Object reference not set to an instance of an object Player.Update () (at Assets/Scripts/Player.cs:32)

I haven't even started on part 10. Writing the Enemy Script yet. I've been stuck here for hours.

avatar image
0

Answer by Simpso · Jun 12, 2016 at 12:18 PM

I had the same issue until i realized my mistake in the Game manager script.

Turns out i wasn't setting the instance of the game manager because of a simple bit of syntax. Coming off the back of coding in VBA where a if statment uses one = , i had missed the c# way of doing things.

Basically the double == was missing from the the below code .

Check that to see if it solves your issue. @wolfcamoedsheep @nickazoid

void Awake() { if (instance == null)

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How does Unity figure out generic component type as Wall in Project: 2D Roguelike tutorial? 0 Answers

Checking if object intersects? 1 Answer

2D Roguelike - moving onto enemies 3 Answers

GUIText Instantiation to show at Asteroid position 0 Answers

Accessing Enemy lifebar prefab 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