Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 gabriel · Apr 21, 2011 at 11:14 PM · errorconsolelogprintunassignedreferenceexcept

How to disable errors in the console?

alt text

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!"); } }

Comment
Add comment · Show 4
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 Peter G · Apr 22, 2011 at 01:45 AM 0
Share

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.

avatar image gabriel · Apr 22, 2011 at 01:50 AM 0
Share

Here's the code maybe you can see what's wrong... (See above)

avatar image Peter G · Apr 22, 2011 at 01:53 AM 0
Share

leftFlame.renderer.enabled = false; rightFlame.renderer.enabled = false; You need to assign an Object to leftFlame and rightFlame in the inspector

avatar image Peter G · Apr 23, 2011 at 11:25 AM 0
Share

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.

1 Reply

· Add your reply
  • Sort: 
avatar image
5

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.

Comment
Add comment · Show 4 · 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 gabriel · Apr 22, 2011 at 01:40 AM 0
Share

I followed a VTC course, and the guy who did the tutorial, never assagined anything in the console...

avatar image gabriel · Apr 22, 2011 at 01:52 AM 0
Share

Here's the code maybe you can see what's wrong... (See above)

avatar image gabriel · Apr 22, 2011 at 05:55 AM 0
Share

I just did, and it keeps telling me exactly the same error. (Assigned the FirstPersonController). Check the image above.

avatar image KyleBlumreisinger · Dec 02, 2017 at 07:03 AM 1
Share

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

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

1 Person is following this question.

avatar image

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


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