Getting entity from RaycastHit?Solved
    if (player != null && !Physics.Raycast(player.eyes.HeadRay(), out hit, float.MaxValue, layers))
    {
        GenericPosition entitiePosition = new GenericPosition(hit.point.x, hit.point.y, hit.point.z);

        // get reference to entity?
        
    }
hit.GetEntity()
In response to Wulf ():
hit.GetEntity()
Hrmm.. I thought that would be it but it did not work for me. Maybe my issue is with the layer object I use?

        [ChatCommand("testla")]
        void testla(BasePlayer player, string command, string[] args)
        {
            var layers =  LayerMask.GetMask("Construction", "Default", "Deployed", "Resource", "Terrain", "Water", "World");

            RaycastHit hit = new RaycastHit();

            if (Physics.Raycast(player.eyes.HeadRay(), out hit, float.MaxValue, layers))
            {
                var entity = hit.GetEntity();
                if (entity != null)
                {
                    PrintToChat(player, $"Looking at {entity.PrefabName}");
                    
                }
            }
        }
​

EDIT: Ahh wait .... it just didn't work on a boat.
Locked automatically