Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Two Quick Beginner Questions
#7
(20-08-2019, 04:51 PM)HenryChinaski Wrote: Thanks for the reply.
I tried your suggestions but I am very sorry that I still have problems getting the player collider. 

Code:
   void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
   {
       foreach (Oni.Contact contact in e.contacts)
       {
           // this one is an actual collision:
           if (contact.distance < 0.01)
           {
               Component collider;
               if (ObiCollider.idToCollider.TryGetValue(contact.other, out collider))
               {
                   Collider ContactCollider = ObiCollider.idToCollider[contact.other] as Collider;

                   Debug.Log(ContactCollider.transform.gameObject.name);
               }
           }
       }
   }

There is a debug log message whenever the softbody touches the ground, but there is no debug log message when the player touches the softbody.

The player has a capsule collider, a rigidbody, an obi collider and an obi rigidbody.

Make sure the player collider's phase is different than that of the softbody particles. Other than that, there's no reason for it to work with one collider but not with the other. I'd need to take a deep look at your setup to figure out the problem.

Also, this line is redundant:
Code:
Collider ContactCollider = ObiCollider.idToCollider[contact.other] as Collider;

You're already retrieving the collider in
Code:
ObiCollider.idToCollider.TryGetValue(contact.other, out collider)

So why accessing the map two times per contact? double performance hit for no reason. Just get rid of the second lookup.
Reply


Messages In This Thread
Two Quick Beginner Questions - by HenryChinaski - 05-08-2019, 01:53 PM
RE: Two Quick Beginner Questions - by josemendez - 07-08-2019, 01:41 PM
RE: Two Quick Beginner Questions - by josemendez - 20-08-2019, 10:04 AM
RE: Two Quick Beginner Questions - by josemendez - 20-08-2019, 05:22 PM