Search Unity

Question A trigger collider is blocking a non-trigger collider

Discussion in 'Editor & General Support' started by LeFuji, Oct 15, 2020.

  1. LeFuji

    LeFuji

    Joined:
    Oct 2, 2018
    Posts:
    18
    Hello everyone!

    I'm starting something in Unity in order to understand better the engine.

    This project rely on soldiers walking through a "lane" on the map, so they consistently chase the objective which is on the other side. The lane itself is a Box Collider with "is Trigger" marked, and when a soldiers walks though it, OnTriggerEnter fires and finds the object which this soldier wants to reach.

    This is my lane. We can check that it extents right on the border of the square on the floor. It does have the is trigger marked. The script merely spawns two nodes (Left node is half visible on the image), and trying to fix this, I created a specific physics layer called Lane which only interacts with the Physical lane...



    This is my soldier. All of it's components are placed in the "Physical" layer of physics, except for the FOV game object, which is on the "Sensor" lane. The script is huge but only contains if for encounters and to check for the nearest cover. After that, animator which only contains an idle and running forward. A capsule collider so I wont fall through the floor and a rigid body, so my sensor can detect enemies, obstacles and covers ahead.



    Thing is, as soon as my lane collider detects my soldier collider, it does block it, making it move upwards. We can also check it in the console where I fired some debug.log messages OnTriggerEnter event. I have also disabled the capsule collider and changed the rigid body to Kinematic just to check, and the lane won't cause me more trouble, also no detecting the OnTriggerEnter and my soldier went through every obstacle possible.



    Any ideas what I can do to fix it?

    Thanks for any help!
     

    Attached Files:

    Last edited: Oct 16, 2020
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,689
    Is your soldier just falling over backwards because his FOV sensor touched something further ahead?

    You could put separate sensor scripts on the FOV vs the base Rigidbody object to find out.

    You can also specify that the RB can only spin around in the Y direction, but is rotation-constrained in X and Z if he is falling over.
     
  3. LeFuji

    LeFuji

    Joined:
    Oct 2, 2018
    Posts:
    18
    Those are excellent ideas, but I've tested them before. I will double check each of of those now, just to be sure:

    I've checked the Freeze Rotation and only Y is enabled, because sometimes the soldiers will need to switch lanes.


    4..png

    My lane originally was 30 units in length. I've adjusted the lane to 20 units, so I could check that was the collision of the soldier with the lane that was causing it. The lane having 20 or 30 units, the soldier behave exactly the same, just as it touches the lane. In this image, I moved to soldier to the northernmost lane, with nothing blocking it yet, and with 30 units long.

    5..png
    And, it just try to become some sort of WW2 spider-man, as soon as it touches the lane collider 7..png

    I'm thinking right now if some sort of double check on each bone? Something an imported asset needs adjustment to properly work with trigger colliders?
     

    Attached Files:

    • 6..png
      6..png
      File size:
      284.7 KB
      Views:
      292