- Home /
How to disable errors in the console?
I want to get rid of errors in the console like this one:
UnassignedReferenceException: The variable leftFlame of 'TurretControl' has not been assigned.
You probably need to assign the leftFlame variable of the TurretControl script in the inspector.
TurretControl.Awake () (at Assets/Scripts/TurretControl.js:12)
I want to see print outputs instead of errors.
Script:
//Turret control script
var target : Transform; var range = 10.0; var leftFlame: GameObject; var rightFlame : GameObject;
static var mode = "idle";
function Awake() { target = GameObject.FindWithTag("Player").transform; leftFlame.renderer.enabled = false; rightFlame.renderer.enabled = false; }
function Update () { if(target && CanAttackTarget()) { //transform.LookAt(target); var targetRotation = Quaternion.LookRotation(target.position - transform.position, Vector3.up); transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 1.2); } }
function CanAttackTarget() { //check if the target is close enough if(Vector3.Distance(transform.position, target.position) > range) { Disengage(); return false; }
var hit : RaycastHit;
//check if there is collision inbetween turrent and target
if(Physics.Linecast(transform.position, target.position, hit))
{
if(hit.collider.gameObject.tag != "Player")
{
Disengage();
return false;
}
else
{
Attack();
return true;
}
}
return true;
}
function Attack() { if(mode != "attack") { InvokeRepeating("FalconAnimate", 2, 0.05); mode = "attack"; } }
function Disengage() { if(mode != "idle") { CancelInvoke(); mode = "idle"; leftFlame.renderer.enabled = false; rightFlame.renderer.enabled = false; } }
function FalconAnimate() { if(leftFlame && rightFlame) { if(leftFlame.renderer.enabled) { leftFlame.renderer.enabled = false; rightFlame.renderer.enabled = true; } else { leftFlame.renderer.enabled = true; rightFlame.renderer.enabled = false; } } else { print("Effects on turrent not set!"); } }
hmmm. I would do it anyway. Seeing the code in the other post, I would try assigning the variables anyway. It looks like his code assumes that you will do that.
Here's the code maybe you can see what's wrong... (See above)
leftFlame.renderer.enabled = false; rightFlame.renderer.enabled = false;
You need to assign an Object to leftFlame and rightFlame in the inspector
well I'm running out of ideas. Did you clear the console and run it again? This kind of error won't just disappear when you assign the variable to the inspector.
Answer by Peter G · Apr 21, 2011 at 11:18 PM
You shouldn't just ignore errors. Do what the error tells you to and it will go away.
I followed a VTC course, and the guy who did the tutorial, never assagined anything in the console...
Here's the code maybe you can see what's wrong... (See above)
I just did, and it keeps telling me exactly the same error. (Assigned the FirstPersonController). Check the image above.
The question was "how to disable errors". "Don't do it" is not an answer. People like me who are looking for how to disable specific error messages find this useless. Always answer the question in the title first and foremost. I'm going to keep searching for how to disable errors.
Your answer
Follow this Question
Related Questions
Error log with line number but without column number. How to solve it? 0 Answers
How do you get console messages in order? 0 Answers
I got an error that will not go away and doesn't seem to have a solution. 2 Answers
Error message help!? 1 Answer
Does any one know how to analyse/read "crash.dmp" file ? 0 Answers