Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Odd collision detection behaviour for objects at non 90 degree angle
#1
Hello

I'm trying to use a script to detect when the gameobject the player gameobject has collided with and then run another line of code once detected.

The issue I am having is the player detects the other gameobject without physically touching it if the other gameobject is rotated at an angle that is not a multiple of 90. What seems to be happening is the other gameobject has an area around it with a rotation of 0-degrees. When the player enters this area it detects the other gameobject. In the screenshot below the white cube is the object I want to detect rotated to a 45-degree angle and the red cube is the area the player is detecting rotated 0-degrees.

   

I've also included a screenshot of the white cube's collider setup.

   

I want to fix this issue so the player only detects the other gameobject when physically colliding with it.

I'm not an experienced programmer and am at a loss for what to do so any help would be greatly appreciated. 

Thank you.

Below is the code I'm using to detect the object the player is colliding with.
Code:
private void Solver_OnCollision(ObiSolver solver, ObiSolver.ObiCollisionEventArgs e)
    {    
        foreach (Oni.Contact contact in e.contacts)
        {
            ObiColliderBase collider = ObiColliderWorld.GetInstance().colliderHandles[contact.bodyB].owner;

            print(collider.transform.gameObject);
Reply


Messages In This Thread
Odd collision detection behaviour for objects at non 90 degree angle - by Moon_Hermit - 20-12-2022, 06:34 PM