Raycast doesn't activate OnTriggerEnter()

Hello,

I have what I assume is a very trivial problem but I cannot for the life of me figure it out. I am writing a simple fog of war system where the “fog” objects disappear when they enter the line of sight of a unit, represented by a Raycast.

I have confirmed my line of sight Raycasts are hitting the fog Colliders. The OnTriggerEnter() method of the fog class runs when it is hit by the unit’s BoxCollider, but not it’s Raycast.
The unit has a RigidBody component and the fog BoxCollider is set to "Is Trigger", and I’m not messing around with any layers.
If anyone has any idea what’s going on here please let me know.

Here are simple scripts for my fog and unit controllers:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FogTmp : MonoBehaviour
{
    void OnTriggerEnter(Collider other)
    {
        Debug.Log("hit by: " + other.name);
    }
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UnitTmp : MonoBehaviour
{
    public float LoS = 12f;
        private void FixedUpdate()
        {
            if (Physics.Raycast(transform.position + new Vector3(1.5f, 0, 0), transform.TransformDirection(Vector3.left), LoS))
            { Debug.Log("hitting!"); }
            Debug.DrawRay(transform.position + new Vector3(1.5f, 0, 0), transform.TransformDirection(Vector3.left) * LoS, Color.green);
        }
    }

OnTrigger doesn’t react to Raycasts , the only thing that OnTriggerX() methods react to are collider to collider collisions.

If you want it to react to the Raycast touching an object , you can just do it directly is the code that call the Physics.Raycast and loop over the results to do whatever you want to do.

EDIT : look at the correction made by the comment under my response

EDIT 2 : quoting Unity docs here

Specifying queryTriggerInteraction allows you to control whether or not Trigger colliders generate a hit, or whether to use the global Physics.queriesHitTriggers setting.

So i guess i want right from the start

Are you sure about this? Physics.Raycast has a specific queryTriggerInteraction option, from the documentation:

“Specifying queryTriggerInteraction allows you to control whether or not Trigger colliders generate a hit”

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UnitTmp : MonoBehaviour
{
    public float LoS = 12f;

    private void FixedUpdate()
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position + new Vector3(1.5f, 0, 0), transform.TransformDirection(Vector3.left), out hit, LoS))
        {
            Debug.Log("Raycast hit: " + hit.collider.gameObject.name);
            // Manually call OnTriggerEnter on the hit object
            hit.collider.gameObject.SendMessage("OnTriggerEnter", GetComponent<Collider>());
        }

        Debug.DrawRay(transform.position + new Vector3(1.5f, 0, 0), transform.TransformDirection(Vector3.left) * LoS, Color.green);
    }
}

lets try it