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 ShrapnelArkonnen · Dec 15, 2012 at 09:32 PM · buildbuild-errorexe

Car Tutorial Raycast Issue since Upgrade Unity 4, Build fails editor works

Hey Guys,

maybe someone has got the same issue since upgrading to U4. I am working with the car tut alternatephysics model and since upgrading to u4 the game works normal in editor mode but the build gives me the following error from the wheel script:

raycastclosestshape:max distance must be greater than zero. at line4: bool onGround...

I double checked it within the console (printed: hit.point, hit.distance, hit.collider, hit.normal, and the starting point of the ray) and the distance the raycast gets is always greater than zero to the next shape. I also put the wheel mesh out of raycast sight for a try...

I didnt change anything within the original CarTut Wheel script, so I dont really understand the problem.

Well I burned the whole last two days and I hope someones got an idea.

 void FixedUpdate () {
 
         Vector3 pos = transform.position;
         up = transform.up;
         RaycastHit hit;
         bool onGround = Physics.Raycast( pos, -up, out hit, suspensionTravel +radius );
         //print ("Distance:" + (suspensionTravel + radius));
         if (onGround && hit.collider.isTrigger)
         {
             onGround = false;
             float dist = suspensionTravel + radius;
             RaycastHit[] hits = Physics.RaycastAll( pos, -up, suspensionTravel +radius);
             foreach(RaycastHit test in hits)
             {
                 if (!test.collider.isTrigger && test.distance <= dist)
                 {
                     hit = test;
                     onGround = true;
                     dist = test.distance;
                     
                 }
             }
         }
 
         if (onGround)
         {
             groundNormal = transform.InverseTransformDirection (inverseLocalRotation * hit.normal);
             compression = 1.0f - ((hit.distance - radius) / suspensionTravel);
             //print ("Compression:" + (1.0f - ((hit.distance - radius) / suspensionTravel)));
             print ("HitPoint:" + (hit.point));
             print ("Position:" + (pos));
             print ("Distance:" + (hit.distance));
             print ("Collider:" + (hit.collider));
             print ("Normal:" + (hit.normal));
             wheelVelo = body.GetPointVelocity (pos);
             localVelo = transform.InverseTransformDirection (inverseLocalRotation * wheelVelo);
             suspensionForce = SuspensionForce ();
             roadForce = RoadForce ();
             body.AddForceAtPosition (suspensionForce + roadForce, pos);
         }
         else
         {
             compression = 0.0f;
             suspensionForce = Vector3.zero;
             roadForce = Vector3.zero;
             float totalInertia = inertia + drivetrainInertia;
             float driveAngularDelta = driveTorque * Time.deltaTime / totalInertia;
             float totalFrictionTorque = brakeFrictionTorque * brake + handbrakeFrictionTorque * handbrake + frictionTorque + driveFrictionTorque;
             float frictionAngularDelta = totalFrictionTorque * Time.deltaTime / totalInertia;
             angularVelocity += driveAngularDelta;
             if (Mathf.Abs(angularVelocity) > frictionAngularDelta)
                 angularVelocity -= frictionAngularDelta * Mathf.Sign(angularVelocity);
             else
                 angularVelocity = 0;
             slipRatio = 0;
             slipVelo = 0;
         }
         
         if (skid != null && Mathf.Abs(slipRatio) > 0.2)
             lastSkid = skid.AddSkidMark(hit.point, hit.normal, Mathf.Abs(slipRatio) - 0.2f,lastSkid);
         else
             lastSkid = -1;
             
         compression = Mathf.Clamp01 (compression);
         rotation += angularVelocity * Time.deltaTime;
         if (model != null)
         {
             model.transform.localPosition = Vector3.up * (compression - 1.0f) * suspensionTravel;
             model.transform.localRotation = Quaternion.Euler (Mathf.Rad2Deg * rotation, maxSteeringAngle * steering, 0);
         }
     }

Thanks ahead.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by ShrapnelArkonnen · Dec 22, 2012 at 12:38 AM

Well, the problem were two scripts used the same name, one in java the other in c#. Deleted the unused one. Thats it. The problem wasnt U4 and not the raycast. It seems U3.... didnt took the script for the build.

I found the solution only lookin for someones with same problem: "build" is corrupted! Remove it and launch unity again! This could be found in the output.log when to build a development build in front of the raycast issue. So I ll always use this log in the future....

Maybe someones gettin the same struggle someday.

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 bobo72a · Sep 21, 2013 at 06:59 AM 0
Share

Which script was the duplicate might I ask?

avatar image ShrapnelArkonnen · Sep 21, 2013 at 11:55 PM 0
Share

Dont $$anonymous$$d, sorry. Just choose "scripts" in the inspector dropdown, you should see all the scripts in your project alphabetical...

avatar image hjohn6000 · Oct 22, 2013 at 03:28 PM 0
Share

Hi

Im having the same problem today, just upgraded to Unity 4.0 and I have the same prob "RaycastClosestShape:max distance must be greater than zero." can you help me out here with abit more Detail, because I diden't find another script that has the same name,

Thank you

would really like if you could help me out here. guess someday is now for me :)

avatar image Shadyfella · Mar 17, 2014 at 11:54 PM 0
Share

Thanks SO much for sharing this! I have been stuck on this for days and the problem was a script I had converted from java to C#. I thought that since it compiled... all was okay... wrong.

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

12 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

Related Questions

Distribute terrain in zones 3 Answers

no suitable applciation records were found 1 Answer

Why does my build project can't connect to sqlite database? 0 Answers

Runs fine in editor but terribly slow as build. 0 Answers

Someone in 2022 is having trouble with unity build and your anitvirus? 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