- Home /
 
               Question by 
               samsam100900 · Jun 15, 2020 at 09:34 AM · 
                bugcollision detectionmeshcolliderfastpick up object  
              
 
              Objects pass through mesh collider without collision (Help me pls)
Hi, I have a problem with my script which allows me to take and throw objects. In short, when I move my object too quickly, the collisions are wierd and the objects pass through the ground. The ground is a mesh collider which has a rigidbody with the collision detection mode set on continious speculative and the objects on continious dynamic. I don't know what to do so thank you for helping me! Here is the script:
     float distance;
     Rigidbody itemRb;
     public float throwForce;
     public GameObject distanceObject;
     public bool isHolding = false;
     void Start()
     {
         itemRb = GetComponent<Rigidbody>();
     }
     void FixedUpdate()
     {
         distance = Vector3.Distance(transform.position, distanceObject.transform.position);
         if (isHolding == true)
         {
             transform.SetParent(distanceObject.transform);
             itemRb.velocity = Vector3.zero;
             itemRb.angularVelocity = Vector3.zero;
             if (distance >= 2f)
             {
                 OnMouseUp();
             }
         }
     }
     void OnMouseDown()
     {
         if (distance <= 2f)
         {
             isHolding = true;
             itemRb.useGravity = false;
         }
     }
     void OnMouseUp()
     {
         isHolding = false;
         itemRb.useGravity = true;
         transform.SetParent(null);
         itemRb.AddForce(distanceObject.transform.forward * throwForce);
     }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Detect collision between kinamatic rigidbodie and gameobject without rigidbody but with colliders 0 Answers
Mesh collider problem with two models next to each other 0 Answers
OnTriggerEnter called one step too late 0 Answers
Mesh Collider not detected by Box Collider Trigger (using unity 2018.4 lts) 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                