Quantcast
Channel: Questions in topic: "missingreferenceexception"
Viewing all 208 articles
Browse latest View live

Missing built in enum reference?

$
0
0
Hello, I am trying to figure out why my build will not compile. I am getting the Error CS0246 saying I am missing an assembly or reference for 'NetworkDisconnection' which is a built in Unity enum. In the code I have the using UnityEngine and using System.Collections, which I know the 'NetworkDisconnection' enum is a part of. Any clue how to fix? This is the code that is throwing the error void OnDisconnectedFromServer( NetworkDisconnection cause ) { Destroy( gameObject ); }

MissingReferenceException on Inspector-assigned values after reloading scene

$
0
0
I have a level scene where gameplay takes place. In this scene, I have a canvas. I also have a PlayerGUI (manager object) that has Inspector-assigned references to the canvas elements it needs to enable/disable depending on the gameplay state. I enter the scene in gameplay and press the pause button to bring up the pause UI (PlayerGUI calls the SetActive(true) method on the GameObject reference to the panel of the pause UI). I then reload the scene using SceneManager.LoadScene, and try to open the pause UI again. This time, I'm given an exception: MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. The exception points to this line: PanelPauseMenu.SetActive(true); I am almost certain this has to be a bug in Unity. When checking the Hierarchy during gameplay, PlayerGUI has a live reference to the correct element (the reference can be double clicked, and the live, correct UI element is highlighted). Does anyone have any idea why this happens? Everything works fine the first time around, but completely fails if the level is loaded again -- it's like the references aren't updated when the level is reloaded, although they appear correct in the Inspector.

Can I check if this.gameObject was destroyed?

$
0
0
Here's a simple version of a coroutine that's running on one of my objects: public IEnumerator PulseOnGround() { while (gameObject.activeInHierarchy) { //do stuff yield return new WaitForFixedUpdate(); if (gameObject == null) yield break; } } This throws a MissingReferenceException when the object is destroyed from another script. It appears that the script keeps running after it's destroyed, but I can't find a way to check if the gameObject still exists from within the script. Is it possible to break this coroutine on destroy from within this script, without using StopCoroutine? Or do I need another script to keep track of whether this script is still alive and call StopCoroutine on any coroutines that might still be running? I'm trying to do this without StopCoroutine because I don't have references to every coroutine that's running, and I would want all of them to stop on destroy anyway.

Missing Reference.

$
0
0
switch (Input.field.text.ToLower()) { case "www.blahblah.saq": // do something when they hit up www.blahblah.saq break; case "www.microsoft.com": // do something else based off the www.microsoft.com URL break; default: // load up the browser image for any "WRONG" URL's break; } Having a bit of an issue, can't really seem to get this on either. It gives 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) Please help?

OnBecameInvisible() Throwing error when game stops

$
0
0
Hello, I tried and searched but did not found any solution to my problem. I call OnBecameInvisible() function from few different scripts. All of them are throwing errors. First one is this part of code: void OnBecameInvisible(){ if (transform.position.x < Camera.main.transform.position.x) { //do stuff } } It says "Assertion failed on expression: 'go.IsActive() && go.GetTag() != 0'". This happens only when I exit play mode. And there is another error on second line of this code: void OnBecameInvisible(){ if (transform.position.x < playerTransform.position.x) { //do stuff } } It says: "MissingReferenceException: The object of type 'Transform' has been destroyed but you are still trying to access it." It happens whenever I exit the play mode. I had my Scene tab closed but nothing. What should I do?

Assigned variable returns null?

$
0
0
I have what I believe to be a very straightforward script that effectively just enabled gameobjects in the scene when certain actions are completed. I'm running into an issue where when i try to enable them they will occasionally evaluate to null and I will hit a missing reference exception as if the object has been deleted - but if i look at the object in the inspector I can see that it is definitely assigned (its a public variable.) stuff I've tried: - I made sure there isn't another instance of this class in the scene that hasn't been initialized properly. there is only one instance, and I can see that its gameobjects are assigned as anticipated. - Reassigning the game objects at runtime. I figured maybe something was weird about how they were assigned, so I tried assigning them manually at run time in the inspector but no joy, it still gives me a missing reference exception - Manually enabling it before trying to reference it. I figured maybe something weird could be happening where its having trouble retrieving a disabled gameobject but that still gave me a missing reference exception. I'll post the code thats enabling it below as well as what it looks like in the inspector but its really about as straightforward as it gets, maybe I'm missing something very simple though. Things that might make this weird : - This class and the objects its enabling are loaded into the scene via asset bundle. unity has historically had some weirdnesses associated with loading asset bundles so maybe theres a bug to do with that in play? - the function gets called as the result of an event being fired elsewhere. I'm not sure why this would matter since it doesnt seem like its a problem with the wrong function being called/the wrong parameter being passed but ive had troubled with events and listeners before. any help would be appreciated. *EDIT here is the stack trace MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. HFN.Ecomuve.TrailerMap.OnPlaceTracerPin (HFN.Ecomuve.TracerModule tracerModule) (at Assets/WisdomTools/Ecomuve/UGUI/Views/Tracer/TrailerMap.cs:32) HFN.Ecomuve.TracerTool.Update () (at Assets/WisdomTools/Ecomuve/UGUI/Views/Tracer/TracerTool.cs:149) ![alt text][1] [1]: /storage/temp/78229-inspector.jpeg using UnityEngine; using System.Collections; using HFN.Common; namespace HFN.Ecomuve { public class TrailerMap : MonoBehaviour { public GameObject farmTracerPin; public GameObject golfTracerPin; public GameObject neighborhood1TracerPin; public GameObject neighborhood2TracerPin; public GameObject toiletTracerPin; public void PlaceTracerPin(TracerModule tracerModule) { switch(tracerModule.tracerTypes) { case TracerId.Farm : Debug.Log(farmTracerPin); farmTracerPin.SetActive(true); break; case TracerId.GolfCourse : Debug.Log(golfTracerPin); golfTracerPin.SetActive(true); break; case TracerId.Neighborhood1 : Debug.Log(neighborhood1TracerPin); neighborhood1TracerPin.SetActive(true); break; case TracerId.Neighborhood2 : Debug.Log(neighborhood2TracerPin); neighborhood2TracerPin.SetActive(true); break; case TracerId.Toilet : Debug.Log(toiletTracerPin); toiletTracerPin.SetActive(true); break; } } public void PlaceTracerPin(Tracer tracer) { switch(tracer.tracerId) { case TracerId.Farm : farmTracerPin.SetActive(true); break; case TracerId.GolfCourse : golfTracerPin.SetActive(true); break; case TracerId.Neighborhood1 : neighborhood1TracerPin.SetActive(true); break; case TracerId.Neighborhood2 : neighborhood2TracerPin.SetActive(true); break; case TracerId.Toilet : toiletTracerPin.SetActive(true); break; } } private void Awake() { TracerTool.onSaveTracer += PlaceTracerPin; } } }

GameObject not in hierarchy missing reference to a script

$
0
0
I have a project in 5.5 beta that has a scene which has a ghost object. it does not show up in the editor hierarchy however if i double click the warning (missing script reference) the scene editor find an object called "GameDrawManager". which is not part of any prefabs nor is it part of the scene what so ever. even after deleting all objects in the scene, at run time there would be an empty hierarchy yet it still gives me the warning. I can also click on the warning which takes me to said invisible object. which is only a transform and a missing behaviour. i managed to get rid of it by creating a new scene and pasting all of the world objects to it

MissingReferenceException: The object of type 'Animator' has been destroyed but you are still trying to access it.

$
0
0
Hi all. I know many other have already asked this kind of question, but still I haven't found an answer which worked for me. The issue is: My game has 2 scenes so far: a **Main Menu** and a **Level 1**. Normally, when my character dies in the game, she just respawns at the latest checkpoint. But if I load Level 1 from the Main Menu, when she dies she respawns already dead with the Player Controller script disabled and I get this error: *"MissingReferenceException: The object of type 'Animator' has been destroyed but you are still trying to access it."* With "already dead" I mean that she gets stuck in the dead animation and the input doesn't work. I guess the input doesn't work because one of the scripts is disabled. And she gets stuck in the animation because the controller is destroyed. But what confuses me is that this happens only when playing this level loaded from the Main Menu. This is the code that runs when she dies: **PLAYER CONTROLLER SCRIPT:** public void Die() //death is called by a KillingObject event { m_bShootingAllowed = false; //to avoid spamming calls to this function KillingObject.OnKill -= Die; Instantiate (DieEffect, m_oTransform.position + DieEffectPosition, m_oTransform.rotation); Debug.Log("Player is dead"); m_oTimer.Start(deathAnimationLength + mk_fTimeToRespawn, Respawn, false, deathAnimationLength, HidePlayerModel); } private void HidePlayerModel() { Debug.Log("hiding player model"); Renderer[] rs = GetComponentsInChildren(); foreach (Renderer r in rs) r.enabled = false; } private void RestorePlayerModel() { Debug.Log("restoring player model"); Renderer[] rs = GetComponentsInChildren(); foreach (Renderer r in rs) r.enabled = true; } private void Respawn() { Debug.Log("Player respawned"); Debug.Log (GameModule.GetInstance().GetCheckpointManager().GetRespawnPosition()); m_oTransform.position = GameModule.GetInstance().GetCheckpointManager().GetRespawnPosition (); RestorePlayerModel(); OnRespawn (); //this is a delegate KillingObject.OnKill += Die; //can die again AllowShooting(); } **PLAYER ANIMATION SCRIPT:** void OnDie() { KillingObject.OnKill -= OnDie; //to avoid spamming calls to this function _animator.Play("Death"); source.clip = deathSounds[Random.Range(0, deathSounds.Length)]; source.volume = .2f; source.Play(); } void OnRespawn() { KillingObject.OnKill += OnDie; _animator.Play("Idle"); source.volume = 1f; } As you can see the player isn't destroyed on death, the model is disabled and enabled after a while (set by the Timer script). The scene is loaded with a simple LoadScene();. Thanks in advance for any help :(

Missing Reference Exception... please help, I am new to this!

$
0
0
I've been working on a 2D game and just finished the attacks and I'm trying to make it so that this works with multiple enemies on the field at the same time. I keep getting this error after I kill one and try to kill the other. Also when I try and hit the second one, it kills the first one. ERROR: MissingReferenceException: The object of type 'Animator' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. UnityEngine.Animator.SetBool (System.String name, Boolean value) (at C:/buildslave/unity/build/artifacts/generated/common/modules/Animation/AnimatorBindings.gen.cs:277) bruteDeath.bruteAnimDeath () (at Assets/Scripts/bruteDeath.cs:41) bruteHealth.Update () (at Assets/Scripts/bruteHealth.cs:36) My scripts: LevelController: using System.Collections; using System.Collections.Generic; using UnityEngine; public class LevelManager : MonoBehaviour { //Adds a defineable delay to the attack public float playerAtAnLength; //Says whether or not the player can attack private bool playerCanAttack; //Use this to reference the playerController script public playerController thePlayer; //Use this to reference the bruteController script public bruteController theBrute; public bruteDeath theBruteDeath; //Used to store the brutes last position. public Vector3 bruteLastPosition; public Vector3 bruteLastRotation; //Adds a defineable delay to the animation public float playerAtAnDelay; //Adds a defineable delay to the actual attack public float playerAcAtDelay; //Tracks the players velocity public float playerVelocity; //Allows you to define the amount that the attack should be moved left public double moveLeftDist; //Player Actual Attack Remove Time is the time that it takes for the attack collider to be removed public float playerAcAtReTi; //Allows me to set the object which would be spawned when the player is attacking public GameObject playerActualAttackCollider; //Is true if the last move was right public bool lastMoveRight; //Allows the conversion of the players position to a double public double playerTransformXDouble; //Allows you to set to players attack x location when looking left public Vector3 playerLocationLeft; //Allows you to define the players x position moved to the left public float playerAttackMovedLeft; // Use this for initialization void Start () { //Defines what thePlayer is in the playerController script thePlayer = FindObjectOfType(); theBruteDeath = FindObjectOfType(); theBrute = FindObjectOfType(); //Starts it out so that the player can attack playerCanAttack = true; } // Update is called once per frame void Update () { // // //All needed to flip the player attack when moving left // // theBruteDeath = FindObjectOfType(); theBrute = FindObjectOfType(); //Sets the playerVelocity to the live playerVelocity playerVelocity = thePlayer.playerVelocity; //Transfers the lastMoveRight variable to this script lastMoveRight = thePlayer.lastMoveRight; //Converts the position to a double playerTransformXDouble = thePlayer.transform.position.x; //Converts the double to a float playerAttackMovedLeft = (float)(playerTransformXDouble - moveLeftDist); //Sets the attack to the left of the player by a certain amount playerLocationLeft = new Vector3(playerAttackMovedLeft, thePlayer.transform.position.y, thePlayer.transform.position.z); } // // // //THIS CODE HAPPENS WHEN THE PLAYER ATTACKS OR ATTEMPTS TO ATTACK: // // // //Is able to be called from the playerController when the player attacks public void playerAttack() { //Will run if the player can attack if(playerCanAttack == true) { //Calls the playerAttackCo() to start StartCoroutine("playerAttackCo"); } } //The Co-routine to add the delay into the attack, so you cant spam attack. public IEnumerator playerAttackCo() { //Makes the player not able to spam the attack button playerCanAttack = false; //Starts both co-routines below StartCoroutine("playerAtAnCo"); //Will run if the player is moving right if(playerVelocity >= 0.1) { StartCoroutine("playerAcAtCoRight"); } //Will run if the player is still if(playerVelocity == 0) { StartCoroutine("playerAcAtCoStill"); } //Will run if the player is moving left if(playerVelocity <= -0.1) { StartCoroutine("playerAcAtCoLeft"); } //Sets the canMove variable in the playerController to false thePlayer.GetComponent().canMove = false; //Adds the actual delay for the number of seconds that playerAttackDelay is defined to. yield return new WaitForSeconds(playerAtAnLength); //Sets the canMove variable in the playerController to true thePlayer.GetComponent().canMove = true; //When the delay is over, the player can attack again. playerCanAttack = true; } //This Co-routine adds enough delay so that the actual animation is played only once public IEnumerator playerAtAnCo() { //Sets the isAttacking variable in the playerController to true thePlayer.GetComponent().isAttacking = 1; //Adds enough delay so that the animation is displayed yield return new WaitForSeconds(playerAtAnDelay); //Sets the isAttacking variable in the playerController to false thePlayer.GetComponent().isAttacking = 0; } //This Co-routine adds the actual damage part into the attack public IEnumerator playerAcAtCoRight() { //Sets the delay for the actual damage to be given yield return new WaitForSeconds(playerAcAtDelay); //Spawns the attack radius Instantiate(playerActualAttackCollider, thePlayer.transform.position, thePlayer.transform.rotation); } public IEnumerator playerAcAtCoLeft() { //Sets the delay for the actual damage to be given yield return new WaitForSeconds(playerAcAtDelay); //Still need to flip instantiate transform position Instantiate(playerActualAttackCollider, playerLocationLeft, thePlayer.transform.rotation); } public IEnumerator playerAcAtCoStill() { //Sets the delay for the actual damage to be given yield return new WaitForSeconds(playerAcAtDelay); //Will run if the last move was right if(lastMoveRight == true) { //Will run and place the attack radius on the right if the player is facing right Instantiate(playerActualAttackCollider, thePlayer.transform.position, thePlayer.transform.rotation); } //Will run if the last move is left if (lastMoveRight == false) { //Will run and place the attack radius on the left if is the player is facing left Instantiate(playerActualAttackCollider, playerLocationLeft, thePlayer.transform.rotation); } } // // // //Will run when brute dies // // // public void bruteActualDeath(){ bruteLastPosition = new Vector3(theBrute.transform.position.x, theBrute.transform.position.y, theBrute.transform.position.z ); theBruteDeath.addDeadBrute(); } } Brute Death: using System.Collections; using System.Collections.Generic; using UnityEngine; public class bruteDeath : MonoBehaviour { private bruteHealth theBrute; public Sprite deadBrute; private Animator myAnim; public float timeToEnd; public LevelManager theLevelManager; public Sprite bruteSprite; public Vector3 brutePosition; public Vector3 bruteRotation; public GameObject deadBody; // Use this for initialization void Start() { theLevelManager = FindObjectOfType(); theBrute = FindObjectOfType(); myAnim = GetComponent(); bruteSprite = GetComponent(); } // Update is called once per frame void Update() { } public void bruteAnimDeath() { myAnim.SetBool("bruteIsDead", true); } public void bruteDeathAnimDone() { myAnim.SetBool("bruteDeathAnimDone", true); theLevelManager.bruteActualDeath(); } public void addDeadBrute() { brutePosition = theLevelManager.bruteLastPosition; Destroy(gameObject); Instantiate(deadBody, brutePosition, theBrute.transform.rotation); } } Brute Health: using System.Collections; using System.Collections.Generic; using UnityEngine; public class bruteHealth : MonoBehaviour { //The health of the brute public float bruteHealthPoints; //References the playerController script private playerController thePlayer; private bruteDeath theBruteDeath; private float playerVelocity; private float playerAt1Dam; // Use this for initialization void Start() { theBruteDeath = FindObjectOfType(); //Actually finds the object with the playerController script thePlayer = FindObjectOfType(); //Sets the player Attack 1 Damage in this script to the defined amount in the playerController playerAt1Dam = thePlayer.playerAttack1Dam; } // Update is called once per frame void Update() { //Checks to see if the brute has run out of health if(bruteHealthPoints <= 0) { //If the brute has no health, then they are removed from the world. Eventually, add an Instantiate with particales theBruteDeath.bruteAnimDeath(); } } //Will run if the player attack 1 happens public void thePlayerAttack1BruteDamage() { //Takes the player attack 1 damage amount away from the brutes health. bruteHealthPoints = bruteHealthPoints - playerAt1Dam; } } I also have a playerController script and bruteController script if you need them. I've been working on this for a few hours and am getting frustrated. Please help!!!!!!!!

Unity error The object of type 'Preview' has been destroyed but you are still trying to access it.

$
0
0
I have this script using UnityEngine; using UnityEditor; [CustomEditor( typeof(DoorPro) )] public class DoorProEditor : Editor { public override void OnInspectorGUI() { DrawDefaultInspector (); //Colors Color red = new Color(1F, 0F, 0F, 1F); Color green = new Color(0F,1F,0F,1F); bool PreviewActive = false; if(Selection.activeGameObject.GetComponent() == null) PreviewActive = false; else PreviewActive = true; if(PreviewActive == false) GUI.color = green; if(PreviewActive == true) GUI.color = red; if(GUILayout.Button("Preview Mode")) { if(PreviewActive == false) { Selection.activeGameObject.AddComponent(); } else { DestroyImmediate(Selection.activeGameObject.GetComponent()); } } } And it runs fine, but I still get the error: MissingReferenceException: The object of type 'Preview' has been destroyed but you are still trying to access it. Where did I go wrong?

MissingReferenceException after loading scene.

$
0
0
I'm making a game with DarkRift API, first the player has to create the server, then the host needs to wait for other players in a lobby before starting the game. When a player connects to a server, the active scene for that player changes with `SceneManager.LoadScene(1, LoadSceneMode.Single)` (I also tried adding `SceneManager.SetActiveScene(SceneManager.GetSceneByBuildIndex(1))` after that line). Here's the problem, if a player leaves the server, the scene of that player changes to the first one ( `SceneManager.LoadScene(1, LoadSceneMode.Single)` ), but if he tries to join again to a server, in the moment when he receives all the DarkRiftAPI messages to sync all the stuff, the script needs to change the texts with the info, but it says that the Text has been destroyed. I putted a `Debug.Log` of the Texts, and in the moment when all the messages are received, the Texts are null, but after the player stops receiving, the Texts are normal. Basically, the first time a player joins a server, everything is normal, but if he disconnects and try to connect to other server, that happens. I tried to change the Script Execution Order but it doesn't fixed it. **EDIT**: I believed when I load the scene again, the variables are the same before the scene unloaded, so in the first call the variables aren't the new Objects, but if I put a `Debug.Log` on Start, the object exists, but on any other void, the object is null.

When loading the scene, I get missing references

$
0
0
I have bunch of managers, like GameManager, LevelManager, UIManager, etc. All of them declare a public static variable of their class type and call it "instance". Then all of them have this code in their Awake void Awake { if (instance != null) Destroy(gameObject); instance = this; DontDestroyOnLoad (gameObject); } Basically they're singletons so that I can reference them easier. When I'm trying to load or reload the level, I get this error: **"The object of type 'GameObject' has been destroyed but you are still trying to access it."** All my managers are in DontDestroyOnLoad section of the scene, i.e. the gameobject and the scripts on them are preserved. I don't understand why the hell am I getting this error when I reload the scene and try to access these statics. Can someone make sense of this? EDIT: @hexagonius @jackishere @RobAnthem @ExtinctSpecie I think the problem here may be deeper since out of all those managers, only a specific one is throwing that error and i have problem debugging it. here's what's happening: The loader is instantiating all the managers like so void Awake () { if (LvlGenerator.instance == null) Instantiate(lvlGenerator); if (GameManager.instance == null) Instantiate(gameManager); //etc. } then GameManager is calling this method upon being instantiated void SetUpNewScene() { SceneManager.LoadScene("Scene1"); LvlGenerator.instance.GenerateLevel(); UIManager.instance.SetUpDeathScreen(); } *here if I omit "SceneManager.LoadScene("Scene1") then the entire thing works fine. It's the loading that screws it. * UIManager for example works fine, and LvlGenerator isn't null either. It goes through and calls GenerateLevel() method. Which looks like this public void GenerateLevel() { transform.position = Vector3.zero; //moves LvlGenerator to 0,0,0 so that we start building from those coordinates StartCoroutine(GenerateLevelCoroutine()); } then it starts the coroutine which is quite some code, I'll cut out most part and leave the one that throws the error (which I don't understand). IEnumerator GenerateLevelCoroutine() { int floorTilesRemaining = levelSize; SpawnFloorTile (); floorTilesRemaining--; while(floorTilesRemaining > 0) { if (floorTilesList.Count > 0) { for (int i = 0; i < floorTilesList.Count; i++) { if (transform.position == floorTilesList [i].transform.position) { // some code } } SpawnFloorTile (); floorTilesRemaining--; } yield return null; } } THIS line **"if (transform.position == floorTilesList [i].transform.position)"** is throwing an error mentioned above (The object of type 'GameObject' has been destroyed but you are still trying to access it.). When I try to debug it, none of the variables there are null or anything. floorTilesList is declared in the same script as the error public List floorTilesList = new List(); I still don't understand why this is happening : (

How to destroy only the collided instance of prefab and not the original one?

$
0
0
I have a cube prefab which i use to instantiate more and more such cubes then later i want to destroy the original cube. Here's the script: public void drawBlock() { tempRand = (int)Random.Range(0, 2); Debug.Log("Random Value=" + tempRand); if (tempRand == 1) { nextBlockPosition = Vector3.forward; } else { nextBlockPosition = Vector3.right; } GameObject blk = (GameObject)Instantiate(nextBlock, rb.position + nextBlockPosition, Quaternion.identity); rb = blk.GetComponent(); rb.useGravity = false; rb.AddRelativeForce(-roadSpeed, 0, -roadSpeed, ForceMode.Impulse); } All the cubes have tag of Road. This is what the Collider does(the one which is reponsible for destroying the cubes) void OnTriggerEnter(Collider col) { if (col.CompareTag("Road")) { Debug.Log("Destroyer Collided with:" + col.name); Destroy(col.gameObject); Debug.Log(col.name + "was destroyed!"); } } The problem is that after one of the block gets destroyed, unity starts to give the error that im trying to ref the destroyed object wchich shudn't be the case because i just clone the original cube some of them are still in the scene when the first one gets destroyed. What am I doing wrong here?

MissingReferenceException when using StartCoroutine() after reloading a scene

$
0
0
I have a coroutine in my script that restarts whenever the player presses the button but after reloading the scene in game causes an error: "MissingReferenceException: The object of type 'PlayerCharacter' has been destroyed but you are still trying to access it." This is the piece of code it error directs to ` if (m_driftModifier == 0.0f) { if (m_modifyDrift != null) { StopCoroutine(m_modifyDrift); m_modifyDrift = null; } float _goal = 0.0f; if (m_horizontalInput[0] > 0.1f) _goal = 1.0f; else if (m_horizontalInput[0] < -0.1f) _goal = -1.0f; else _goal = 0.0f; m_modifyDrift = StartCoroutine(moveDrift(_goal, 1)); }` This error seems to only happen if i reload the scene after it has been loaded once, it works normally otherwise.

Unassigned Reference Exception ?

$
0
0
Hello, I have strange problem with my code and I'm not sure how to tackle that. So I have : -Generator object with script below as prefab. -Solar Panel object with button, text and image components (4 children) also prefabed -I have added Solar Panel to the Generator object in inspector as a prefab -I have added Generator to Solar Panel Button and BuySolarPanel() method as OnClick() event also as a prefab; I want this button to instatiate (which it does) and then after clicking it change one if it's text components, but I got missing reference error. I'm sure everything is connected in Inspector and it points me to the last line of code `myText = solarPanel.GetComponentsInChildren();` Here's the code : public GameObject[] buildObjectsArray; public GameObject parentObject; private GameObject solarPanel; private int energy; private int objectCounter = 0; private void Start() { solarPanel = buildObjectsArray[0]; } private void Update() { if (energy == 100 && objectCounter == 0) { Instantiate(solarPanel, parentObject.transform); objectCounter++; Debug.Log(objectCounter); } } public void BuySolarPanel() { Text[] myText; myText = solarPanel.GetComponentsInChildren(); }

MissingRefrenceException help for enemyai

$
0
0
I have some code for a simple ai. My game has a wave system and respawning but when the player dies the game stops and I get this error MissingRefrenceException The object type "Transform" has been destroyed but you are still trying to access it. I know I have to put in a statement to check if the transform is null but I just don't know where or what to do if it is null. Any help is appreciated, here is the code. using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemyAI : MonoBehaviour { public Transform target; public int moveSpeed; public int rotationSpeed; private Transform myTransform; // Use this for initialization void Awake() { myTransform = transform; } void Start() { GameObject go = GameObject.FindGameObjectWithTag("Player"); target = go.transform; } // Update is called once per frame void Update() { Vector3 dir = target.position - myTransform.position; dir.z = 0.0f; // Only needed if objects don't share 'z' value if (dir != Vector3.zero) { myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.FromToRotation(Vector3.right, dir), rotationSpeed * Time.deltaTime); } //Move Towards Target myTransform.position += (target.position - myTransform.position).normalized * moveSpeed * Time.deltaTime; } }

Unity_5.6.1f1 >> Unity_5.5.0f3 - Animation problems (missing reference)...

$
0
0
Hi, I'm having the fallowing problem: I created some animations on the actual version of Unity (Unity_5.6.1f1), but the people who I'm working with is using an older version (Unity_5.6.1f1), so when they opened some animations I did, there was a lot of missing references... ... There is a way to solve this problem without the need of redo all these animations? ![alt text][1] [1]: /storage/temp/95261-animationproblem.png

AudioSource missing reference after SceneManager.LoadScene

$
0
0
Hi there, I am encountering the weirdest issue, that I will try to break down in the easiest way possible. My game is a one scene only. Many objects in this scene, all with different components in them. The game runs fine in editor, compiles just fine as well. When I run the game (regardless of the platform), everything is perfect, except that, when the player dies I use SceneManager.LoadScene() to reload the current scene. However, while level loading works fine, I suddenly gets my audio source on one of my object to throw a missing reference (component destroyed) when I try to access it in my script ( as = GetComponent() ). I checked in the editor after reloading my scene and the audio source is definitely there. If I quit the game completely and re-launch, everything is fine again. I tried my ways of tricking the engine to re-load completely (for example, I load a n empty scene which purpose is to load the main scene again) to no avail. Note that this is happening in the editor AND on the final build. Anyone already encountered these? I assume there is a memory issue.

MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.

$
0
0
Hello I have gotten this error message, but just having hard time to find out in which script where this exception was cast. Can anyone show me a way to find out which script is the culprit? Many thanks.

Player Settings Missing Options

$
0
0
![alt text][1]When I open player Settings for my iOS game in unity it only gives me a tab for resolution. The other tabs are missing. The resolution tab doesn't work either it just shows up. If I switch it to Debug mode I get more options but is there a way to fix this. The console is also giving this error. ullReferenceException: Object reference not set to an instance of an object UnityEditor.PlayerSettingsEditor.BeginSettingsBox (Int32 nr, UnityEngine.GUIContent header) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs:601) UnityEditor.PlayerSettingsEditor.ResolutionSectionGUI (BuildTargetGroup targetGroup, ISettingEditorExtension settingsExtension) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs:774) [1]: /storage/temp/100362-screen-shot-2017-08-21-at-105418-pm.png
Viewing all 208 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>