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 /
This question was closed Sep 27, 2013 at 02:06 AM by clunk47 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by kaini_industries · Sep 26, 2013 at 10:27 PM · rigidbodycollidermesh

collision between a rigidbody and a mesh collider not working

Hi all,

I'm currently making a simple tiltable ball and maze game. My ball and maze are both FBXs imported from 3DS Max. I have the ball set up with a rigidbody and a sphere collider, and the maze is a mesh collider. Upon preview, the ball sits in the maze - i.e. it doesn't fall through it. But when I tilt the maze, it passes straight through the floor. I have read that there's a problem with this with small meshes, but i intentionally made my maze object quite large (160x160 generic 3DS units) to be on the safe side.

I'm not sure if it's an error in the setup, or the code. Here's my (rather inefficient, i admit) code:

 #pragma strict
 
 var rotationAmount = 1;
 var xClamp = 30f;
 var yClamp = 30f;
  
 function Update()
 {
     
     //rotating the maze
     if(transform.localEulerAngles.x < xClamp ){  
         transform.Rotate (Input.GetAxis("Vertical") * -rotationAmount, 0, 0);
     } else if (transform.localEulerAngles.x > (360-xClamp)){  
            transform.Rotate (Input.GetAxis("Vertical") * -rotationAmount, 0, 0);
     }  
     
     if(transform.localEulerAngles.z < yClamp ){  
         transform.Rotate (0, 0, Input.GetAxis("Horizontal") * rotationAmount);           
     } else if (transform.localEulerAngles.z > (360-yClamp)){  
         transform.Rotate (0, 0, Input.GetAxis("Horizontal") * rotationAmount);           
     }  
 
     //clamp rotation
     if(transform.localEulerAngles.z >= yClamp && transform.localEulerAngles.z < (360-yClamp)){  
         if(transform.localEulerAngles.z < 180){  
             transform.localEulerAngles.z = (yClamp-0.01);  
         } else{  
             transform.localEulerAngles.z = ((360-yClamp)+0.01);  
         }  
     }  
     
     if(transform.localEulerAngles.x >= xClamp && transform.localEulerAngles.x < (360-xClamp)){  
         if(transform.localEulerAngles.x < 180){  
             transform.localEulerAngles.x = (xClamp-0.01);  
         } else{  
             transform.localEulerAngles.x = ((360-xClamp)+0.01);  
         }  
     }
     
     if(transform.localEulerAngles.y != 0){  
         transform.localEulerAngles.y = 0;  
     }
 
     //debug code - detect if nothing is pressed           
     if ((Input.GetAxis("Vertical") == 0) && (Input.GetAxis("Horizontal") == 0)){
         Debug.Log("Nothing is pressed.");
     }
 }
 
 function OnGUI ()
 {
     var xRotation = Mathf.Round(transform.localEulerAngles.x * 10) / 10;
     var zRotation = Mathf.Round(transform.localEulerAngles.z * 10) / 10;
     GUI.Box(Rect(10,10,200,130),"X Rotation:"+xRotation+"\nZ Rotation:"+zRotation);
 }

Any ideas would be most welcome!

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

  • Sort: 
avatar image
0
Best Answer

Answer by kaini_industries · Sep 26, 2013 at 10:31 PM

never mind, solved it. it was that the mesh and the rigidbody were in contact at startup. i moved the ball a fraction up and it's picking it up now.

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

Follow this Question

Answers Answers and Comments

15 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

Related Questions

Unreliable collision detection between rigidbody and mesh collider 1 Answer

Workaround to Non-Convex mesh colliders with non-Kinematic RigidBodies? 1 Answer

How to remove internal triangle/faces when combining mesh 0 Answers

Why attach a kinematic rigidbody to a collider that moves a lot? 1 Answer

Rigidbody objects not colliding. 4 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