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 Cheetoturkey · Jul 02, 2013 at 02:38 PM · errorterraingenerationminecraft

Object Refrence Not Set To An Instance Of An Object?

Im Trying To make a minecraft type Terrain Generation Script and it gave me this error :
NullReferenceException: Object reference not set to an instance of an object Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name) UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name) Chunk.Generate () (at Assets/Script/Chunk.js:20) Chunk.Start () (at Assets/Script/Chunk.js:7)

heres my script:

var cubes : GameObject; var spawnInterval = 3.0; var heightScale = 5.0;

 function Start()
 {
 Generate();
 }
 public function PerlinNoise(x : float, y : float) : float
 {
 var noise : float = Mathf.PerlinNoise( x / heightScale, y / heightScale);
 return noise * heightScale;;
 }
 function Generate()
 {
     for (var y = -4; y < 5; ++y)
     for (var x = -4; x < 5; ++x)
     {
     var Cube : GameObject = Instantiate(cubes);
     Cube.transform.position = Generate.transform.position + Vector3(x,PerlinNoise(x,y),y);
     }
 }
Comment
Add comment · Show 3
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 Em3rgency · Jul 02, 2013 at 02:47 PM 0
Share

Did you remember to drag in the cubes game object in the inspector?

avatar image Cheetoturkey · Jul 02, 2013 at 02:49 PM 0
Share

yea thats not the problem :/

avatar image Immanuel-Scholz · Jul 02, 2013 at 02:52 PM 0
Share

What line is the error? And shouldn't that "Generator..." in line 16 be "`this.transform.position`" ins$$anonymous$$d?

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by lighting · Jul 02, 2013 at 02:50 PM

I think that above error indicates that getter doesn't work: what is Generate in your code ? Do you have it as public GameObject defined somewhere else ? Or it's mistake, because your method has name "Generate".

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 Cheetoturkey · Jul 02, 2013 at 02:53 PM 0
Share

yes thank you, i guess i didnt see that

avatar image
0

Answer by bonamoogy · Dec 09, 2018 at 11:10 PM

How i solved this? nullrefrenceExcepton = Object refrence not set to instance object

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class CrossHair : MonoBehaviour {

 [SerializeField] Texture2D crossHairImg;
 [SerializeField] int size;
 [SerializeField] float maxAngle;
 [SerializeField] float minAngle;

 float lookHeight;

 public void LookHeight(float value)
 {
     lookHeight += value;

     if (lookHeight > maxAngle || lookHeight < minAngle)
         lookHeight -= value;
 }

 private void OnGUI()
 {
     Vector3 screenPosition = Camera.main.WorldToScreenPoint(transform.position);
     screenPosition.y = Screen.height - screenPosition.y;
     GUI.DrawTexture(new Rect(screenPosition.x, screenPosition.y - lookHeight, size, size), crossHairImg);
 }

}

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

19 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

Related Questions

This script really makes my game lag! 1 Answer

Minecraft (Cube) Terrain 1 Answer

Voxel based Terrain generation. Pointers please. 2 Answers

How do I make a minecraft like terrain? 0 Answers

World Generation with Interesting Terrain 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