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 EBR · Apr 16, 2014 at 06:01 AM · errorscript errorisnormalized

Confusing error messages, !IsNormalized and NxRay direction not valid

I am getting weird errors from my script, I do not understand why. I have looked up these errors but I can't find anyone who has gotten it for the same reason. Most other people have gotten the errors from lens flares on their cameras which I don't understand. The errors are:

  1. NxRay direction not valid: must be unit vector. UnityEngine.Physics:Linecast(Vector3, Vector3, Int32)

  2. !IsNormalized (ray.GetDirection ()) UnityEngine.Physics:Linecast(Vector3, Vector3, Int32)

  3. !IsNormalized (dir)

This is the bit of code it is from I have commented on the line of the error.

 void Cover()
     {
         Vector3[] covers = new Vector3[100];
         List<Vector3> potential = new List<Vector3>();
 
         NavMeshHit navhit;
 
         for(int i = 0; i < covers.Length - 1 ; i++)
         {
             NavMesh.FindClosestEdge(transform.position + Random.insideUnitSphere * 5, out navhit, passableMask:1);
 
             covers[i] = navhit.position;
             if(Physics.Linecast(navhit.position, sensors.eyes.playerPosition, ~mask) ) // Error happens on this line
             {
                 potential.Add(covers[i]);
             }
         }
 
         if(!hascoverpos)
         {
             hascoverpos = true;
             chosen = potential[0];
 
         }
         if(!Physics.Linecast(chosen, sensors.eyes.playerPosition, ~mask) ) 
         {
             Debug.Log ("Recalculating...");
             hascoverpos = false;
         }
 
         print("Potential Covers = " + potential.Count);
         print("All Covers = " + covers.Length);
 
         TargetDestination = chosen;
     }


Can anyone help me? thanks

Comment
Add comment · Show 8
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 EBR · Apr 16, 2014 at 06:07 AM 0
Share

I should add that as far as I know the script seems to work, I can't see what's going wrong.

avatar image Benproductions1 · Apr 16, 2014 at 09:55 AM 0
Share

What line are the errors on?

avatar image Graham-Dunnett ♦♦ · Apr 16, 2014 at 10:26 AM 1
Share

The errors are all saying the same thing. There is a direction vector and it's length is not 1. Since it happens on your line 13, my guess is that the start and end values you pass into Linecast do not make a direction, possibly because they have the same value, or one of the vectors is invalid in some way. If both vectors were valid, then Unity and/or PhysX ought to be able to make a direction vector from end-start and then normalise it.

avatar image EBR · Apr 16, 2014 at 10:44 AM 0
Share

The errors happen on lines 13 and 25, they both are pretty much the same thing, linecasts

avatar image EBR · Apr 16, 2014 at 10:45 AM 0
Share

Thank you Graham I will try to see where the two points are and check if they have the same value

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

22 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 avatar image avatar image avatar image

Related Questions

Run-Time Errors! Particle Instantiations 1 Answer

Help with script 1 Answer

How to fix !IsNormalized (dir) error 2 Answers

Can't add script to anything error 1 Answer

raycast error 1 Answer


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