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 /
  • Help Room /
This question was closed Mar 21, 2016 at 09:53 PM by GoldRegin for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by GoldRegin · Mar 20, 2016 at 07:19 PM · c#scripting problem

Problem with c# script

Hi! I'm following a TD game tutorial and I encountered error I can't fix myself. link to guide - https://www.raywenderlich.com/107525/create-tower-defense-game-unity-part-1

I'm at - Check That It All Works

This is error I get in console - NullReferenceException: Object reference not set to an instance of an object SpawnEnemy.Start () (at Assets/SpawnEnemy.cs:12)

I'm very new to unity so expect mistakes average users wouldn't make.

Script with an error:

using UnityEngine; using System.Collections;

public class SpawnEnemy : MonoBehaviour {

 public GameObject[] waypoints;
 public GameObject testEnemyPrefab;

 void Start()
 {
     Instantiate(testEnemyPrefab).GetComponent<MoveEnemy>().waypoints = waypoints;
 }

}

Comment
Add comment · Show 7
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 GoldRegin · Mar 20, 2016 at 07:26 PM 0
Share

screenshot of the script

http://scr.hu/6sn8/7aaqd

avatar image JincSoft GoldRegin · Mar 21, 2016 at 02:40 AM 0
Share

Do you have all the GameObjects assigned in the Unity inspector?

avatar image GoldRegin JincSoft · Mar 21, 2016 at 11:25 AM 0
Share

Yes. When I put "enemy" nothing appears - http://scr.hu/6sn8/nzns4

but when I put child of enemy (sprite) in appears in the middle of map - http://scr.hu/6sn8/w1dnq

avatar image brain56 · Mar 21, 2016 at 01:11 PM 0
Share

Copy and paste your script on your question. The link you gave seems to have already expired, I'm seeing a 404.

avatar image GoldRegin brain56 · Mar 21, 2016 at 03:08 PM 0
Share

Updated question and here's new link http://scr.hu/6sn8/n18ix

avatar image Ali-hatem · Mar 21, 2016 at 05:26 PM 0
Share

have you attached the $$anonymous$$oveEnemy script to the Enemy prefab ?

avatar image GoldRegin Ali-hatem · Mar 21, 2016 at 09:53 PM 0
Share

This was a problem. Fixed it. Thanks for help.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

131 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 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 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 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 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 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 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 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

Finding the max Y position value in a list of game objects and assigning it to a variable? 0 Answers

Grading system not working 1 Answer

Running C# Function from JS file 0 Answers

Hololens sharing example 1 Answer

Why can't I call a function within the same class? (Or: how does unity handle instancing?) 0 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