Синтаксис:
Используется csharp
public class UnitASensor : MonoBehaviour
{
public UnitController Main;
}
void OnTriggerEnter(Collider otherUnit)
{
if (otherUnit.gameObject.CompareTag("unitback"))
{
Main.AllyAhead = true;
}
else if (otherUnit.gameObject.CompareTag("unitnose"))
{
Main.EnemyAhead = true;
Main.HPred = otherUnit.GetComponent<UnitController>();
}
}
{
public UnitController Main;
}
void OnTriggerEnter(Collider otherUnit)
{
if (otherUnit.gameObject.CompareTag("unitback"))
{
Main.AllyAhead = true;
}
else if (otherUnit.gameObject.CompareTag("unitnose"))
{
Main.EnemyAhead = true;
Main.HPred = otherUnit.GetComponent<UnitController>();
}
}
И есть главный скрипт, который должен принять то, какой триггер обнаружил скрипт сканер:
Синтаксис:
Используется csharp
public class UnitController : MonoBehaviour
{
public UnitController HPred;
}
{
public UnitController HPred;
}
Я хочу с помощью главного скрипта обратиться и изменить переменные в скрипте объекта, попавшего в сканер.
Суть проблемы: Сканер не передает главному скрипту назначение объекта в HPred, т.е. даже при регистрации самим сканером объекта, но передачи привязки переменной не происходит. Как быть с этой строкой: Main.HPred = otherUnit.GetComponent<UnitController>(); ?