1. I get position foundation

    bool FindRayEntity(Vector3 sourcePos, Vector3 sourceDir, out Vector3 point, out BaseEntity entity)
    {
    RaycastHit hitinfo;
    entity = null;
    point = default(Vector3);

    if (!Physics.Raycast(sourcePos, sourceDir, out hitinfo, 1000f, rayLayer)) { return false; }

    point = hitinfo.point;
    entity = hitinfo.GetEntity();
    return true;
    }

    Set position foundation in the same Vector3 and the Quaternion

    GameManager.server.CreateEntity("assets/prefabs/building core/foundation/foundation.prefab",
    Vector3(entity.transform.position),
    Quaternion(entity.transform.rotation))

    but the foundation set at an angle
     
  2. Use Quaternion.identity instead of Quaternion(entity.transform.rotation)?