- Home /
Unity Crashes On FirstPersonController.GetComponent!!!
When I Use .GetComponent("ScriptName").enabled = true; For The Objects With Blue Font In The Hierarchy, Unity Crashes (Quits). Please Help!!!
here is the script:
var buttonType : String = "Button Type";
var mainCharacter : GameObject;
var character3D : GameObject;
var car : GameObject;
var mainCamera : GameObject;
var gui1 : GameObject;
var gui2 : GameObject;
var guix : GameObject;
function OnMouseDown ()
{
if(buttonType == "Drive")
{
mainCharacter.GetComponent("Third Person Controller").enabled = false;
mainCharacter.GetComponent("Third Person Camera").enabled = false;
mainCharacter.GetComponent("Character Controller").enabled = false; //Disables Main Character And It's Camera Follow
character3D.GetComponent("Skinned Mesh Renderer").enabled = false; //Hides Main Character
car.GetComponent("Car").enabled = true; //Activates Car Script
mainCamera.GetComponent("Car Camera").enabled = true; //Activates Car Camera
gui1.GetComponent("GUITexture").enabled = false;
gui2.GetComponent("GUITexture").enabled = false;
guix.GetComponent("GUITexture").enabled = false; //Disables GUI's
}
}
mainCharacter is 3rd Person Controller character3d is a 3d model inside 3rd person controller (bip pelvis) car is a car from CarTutorial Unity crashes on 3rd person controller.
unity crashes. i tried creating an exe but the game quits anyway
Btw, you asked this question now 3 times, so if you pinned it down to a certain script, can you finally give more information about the faulty script?
i added a script in question, also i found that it crashes on prefabs with blue font in hierarchy
Answer by Bunny83 · Sep 27, 2012 at 01:24 PM
So it's probably your ScriptName-script which causes the crash when you enable it. Maybe an infinite loop in Start or Update.
Short question, short answer.
Feel free to **edit** your question to add more details.
Your answer
![](https://koobas.hobune.stream/wayback/20220613081517im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Error in code I cannot fix 1 Answer
Stuck on splash screen android 0 Answers
Build Iphone Issue 0 Answers
Unity Editor silently crashes straight away no error logs 1 Answer
Create a game objective. 0 Answers