public void AddUnity(GameObject unityToAdd, int typeId) { GameManager.instance.SetUnit(); UnityController u = unityToAdd.GetComponent <UnityController>(); u.StablishUnit(unitScriptable.units[typeId].levelsDescription[DataController.instance.unitsData.units[typeId].level], unitScriptable.units[typeId].typeName); unities.Add(u); SearchInteractableObjects(u.transform.position, u.lightRange); RaycastHit hit; int layerMask = 1 << 8; Ray ray = new Ray(new Vector3(unityToAdd.transform.position.x, unityToAdd.transform.position.y + 30, unityToAdd.transform.position.z), -unityToAdd.transform.up); /*Vector3 up = unityToAdd.transform.TransformDirection(Vector3.up) * 10; * Debug.DrawRay(unityToAdd.transform.position,up, Color.green,10);*/ if (Physics.Raycast(ray, out hit, 30)) { if (hit.transform.CompareTag("Shadow")) { unityToAdd.GetComponent <UnityController>().myTextCoord = hit.textureCoord; if (shadow == null) { shadow = hit.transform.GetComponent <ShadowController>(); shadow.SetUnit(hit.textureCoord, unityToAdd.GetComponent <UnityController>().lightRange); } else { shadow.SetUnit(hit.textureCoord, unityToAdd.GetComponent <UnityController>().lightRange); } } } }