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 Nov 27, 2015 at 06:57 PM by Ashia40 for the following reason:

Resolved

avatar image
0
Question by Ashia40 · Nov 27, 2015 at 04:50 PM · c#gameobjectinstantiatescript error

instantiate a gameobject since another script

Hello people, I have a small problem.

In fact I would want to instantiate a gameobject since another script.

Here is the error that I reçoi:NullReferenceException: Object references not set to the year authority of the object year GenDongeon.geng () (at Assets Assets/Scripts/GenDongeon.cs:30 Scripts) GenDongeon+pause > c __ Iterator0. MoveNext () (at Assets Assets/Scripts/GenDongeon.cs:21 Scripts)

Thank you.

Sorry for my bad English, because I am French.

Script Salles :

 using UnityEngine;
 using System.Collections;
 
 public class Salles : MonoBehaviour {
 
     public GameObject [] salleg1;
     public GameObject [] salled1;
     public GameObject [] salleu1;
     public GameObject [] salleb1;
 
     public static GameObject [] salleg;
     public static GameObject [] salled;
     public static GameObject [] salleu;
     public static GameObject [] salleb;
 
     public static int salg;
     public static int sald;
     public static int salu;
     public static int salb;
 
     void start(){
 
         salleg = new GameObject[salleg1.Length];
         salled = new GameObject[salled1.Length];
         salleu = new GameObject[salleu1.Length];
         salleb = new GameObject[salleb1.Length];
 
         salg = salleg1.Length;
         sald = salled1.Length;
         salu = salleu1.Length;
         salb = salleb1.Length;
 
         for(int a=0;a<salleg1.Length;a++){
             salleg[a] = salleg1[a];
         }
         for(int b=0;b<salled1.Length;b++){
             salled[b] = salled1[b];
         }
         for(int c=0;c<salleu1.Length;c++){
             salleu[c] = salleu1[c];
         }
         for(int d=0;d<salleb1.Length;d++){
             salleb[d] = salleb1[d];
         }
     }
 }

Script GenDongeon :

 using UnityEngine;
 using System.Collections;
 
 public class GenDongeon : MonoBehaviour {
 
     public bool g;
     public bool d;
     public bool u;
     public bool b;
 
     public int timep;
 
     void Start () {
 
         StartCoroutine (pause());
 
     }
 
     public IEnumerator pause(){
         yield return new WaitForSeconds(timep);
         geng();
         gend();
         genu();
         genb();
     }
 
     void geng(){
         if(g==true){
             int rand = Random.Range (0,Salles.sald);
             Instantiate (Salles.salled[rand],new Vector3(this.transform.position.x-8,this.transform.position.y,0),Quaternion.identity);
         }
     }
 
     void gend(){
         if(d==true){
             int rand = Random.Range (0,Salles.salg);
             Instantiate (Salles.salleg[rand],new Vector3(this.transform.position.x+8,this.transform.position.y,0),Quaternion.identity);
         }
     }
 
     void genu(){
         if(u==true){
             int rand = Random.Range (0,Salles.salb);
             Instantiate (Salles.salleb[rand],new Vector3(this.transform.position.x,this.transform.position.y+8,0),Quaternion.identity);
         }
     }
 
     void genb(){
         if(b==true){
             int rand = Random.Range (0,Salles.salu);
             Instantiate (Salles.salleu[rand],new Vector3(this.transform.position.x,this.transform.position.y-8,0),Quaternion.identity);
         }
     }
 }
 

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

  • Sort: 
avatar image
0
Best Answer

Answer by pekalicious · Nov 27, 2015 at 05:58 PM

In Salles, "start" method should be "Start". Case matters.

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
avatar image
0

Answer by Ashia40 · Nov 27, 2015 at 06:56 PM

Thank you.

Comment
Add comment · Show 1 · 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 pekalicious · Nov 27, 2015 at 06:58 PM 0
Share

No problem. Please accept my answer as correct. Thanks.

Follow this Question

Answers Answers and Comments

40 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

Related Questions

Instantiate as child for gameobjects with tag 1 Answer

No gameobject instance again in update 1 Answer

How to instantiate a game object every time when space key is pressed 2 Answers

Moving a spawned object in a direction 1 Answer

How can I instantiate a object on the world coordinates 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