В самой Unity не появляется ссылка на объект.
Добавлено: 12 ноя 2019, 20:38
В самой Unity не появляется ссылка на объект.
Вечер добрый.
Собственно проблема такая.
https://pastenow.ru/e12eeffba9e30fa911e9db0b03cc0b85
Открываю, чтобы выбрать объект, куда пропихнуть переменную bool, а там пусто...
Писал такой же скрипт для другой переменной, все было.
Даже не знаю, с чем такое связано...
Есть два скрипта.
1й. TheSpellCollision (Висит на префабе)
using UnityEngine;
public class TheSpellCollision : MonoBehaviour
{
public AIGame spelldestr;
void Awake()
{
spelldestr.spelldestroy = false;
}
void OnTriggerEnter2D(Collider2D other)
{
switch (other.gameObject.tag)
{
case "The_Ball":
spelldestr.spelldestroy = true;
Destroy(gameObject);
break;
case null:
spelldestr.spelldestroy = false;
break;
}
}
}
2й AIGame (Висит на Главной камере)
/*using System.Collections;
using System.Collections.Generic;*/
using UnityEngine;
public class AIGame : MonoBehaviour
{
private float Player01liveEnergy = 1f;
private float Player02liveEnergy = 1f;
public bool Player01inning;
public bool Player02inning;
public bool BallAIGameGoal;
public float CoordinateBallXY;
public bool spelldestroy;
public int NumberSpell;
// переменная здоровья для отправки в Скрипт Player*Health
public Player01Health Player01EnergyToLive;
public Player02Health Player02EnergyToLive;
void FixedUpdate()
{
//Debug.Log("Состояние щитов игроков" + "01" + Player01inning + "02" + Player02inning);
//проверка на касание щитов игроков мячом. Вызов метода
if (Player01inning || Player02inning)
{
PlayerInning();
}
if (BallAIGameGoal)
{
BallGameGoal();
}
Player01EnergyToLive.fill01 = Player01liveEnergy;
Player02EnergyToLive.fill02 = Player02liveEnergy;
//Проверка на SpellDestroy
if (spelldestroy)
switch (NumberSpell)
{
case 0:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 1:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 2:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 3:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 4:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 5:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 6:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 7:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 8:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 9:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
}
}
void PlayerInning() // метод обработки касания щитов игроков мячом
{
if (Player01inning)
{
Player01inning = true;
Player02inning = false;
//Debug.Log("Касание щита Первого игрока" + Player01inning);
}
if (Player02inning)
{
Player02inning = true;
Player01inning = false;
//Debug.Log("Касание щита Второго игрока" + Player01inning);
}
}
void BallGameGoal()
{
if (Player01liveEnergy <= 0f)
{
Player01liveEnergy = 0f;
}
if (Player02liveEnergy <= 0f)
{
Player02liveEnergy = 0f;
}
if (CoordinateBallXY > 0f & BallAIGameGoal)
{
Player01liveEnergy = Player01liveEnergy - .2f;
}
if (CoordinateBallXY < 0f & BallAIGameGoal)
{
Player02liveEnergy = Player02liveEnergy - .2f;
}
}
}
На всякий случай 3й. (Тут все работает)
using UnityEngine;
public class BalCollision : MonoBehaviour
{
public GameObject[] objects;
public GameObject[] ScorePrefabs;
public AIGame cudgel01;
public AIGame cudgel02;
public AIGame Player01;
public AIGame Player02;
void Awake()
{
Instantiate(objects[Random.Range(0, 9)]);
}
void OnTriggerEnter2D(Collider2D other)
{
// Debug.Log(cudgel01);
switch (other.gameObject.tag)
{
case "TheWith":
Destroy(other.gameObject);
Instantiate(objects[Random.Range(0, 9)]);
break;
case "TheBird":
Destroy(other.gameObject);
//Instantiate(ScorePrefabs[0]);
break;
case "cudgel01":
cudgel01.Player01inning = true;
cudgel02.Player02inning = false;
break;
case "cudgel02":
cudgel01.Player02inning = true;
cudgel02.Player01inning = false;
break;
}
}
}
Вечер добрый.
Собственно проблема такая.
https://pastenow.ru/e12eeffba9e30fa911e9db0b03cc0b85
Открываю, чтобы выбрать объект, куда пропихнуть переменную bool, а там пусто...
Писал такой же скрипт для другой переменной, все было.
Даже не знаю, с чем такое связано...
Есть два скрипта.
1й. TheSpellCollision (Висит на префабе)
using UnityEngine;
public class TheSpellCollision : MonoBehaviour
{
public AIGame spelldestr;
void Awake()
{
spelldestr.spelldestroy = false;
}
void OnTriggerEnter2D(Collider2D other)
{
switch (other.gameObject.tag)
{
case "The_Ball":
spelldestr.spelldestroy = true;
Destroy(gameObject);
break;
case null:
spelldestr.spelldestroy = false;
break;
}
}
}
2й AIGame (Висит на Главной камере)
/*using System.Collections;
using System.Collections.Generic;*/
using UnityEngine;
public class AIGame : MonoBehaviour
{
private float Player01liveEnergy = 1f;
private float Player02liveEnergy = 1f;
public bool Player01inning;
public bool Player02inning;
public bool BallAIGameGoal;
public float CoordinateBallXY;
public bool spelldestroy;
public int NumberSpell;
// переменная здоровья для отправки в Скрипт Player*Health
public Player01Health Player01EnergyToLive;
public Player02Health Player02EnergyToLive;
void FixedUpdate()
{
//Debug.Log("Состояние щитов игроков" + "01" + Player01inning + "02" + Player02inning);
//проверка на касание щитов игроков мячом. Вызов метода
if (Player01inning || Player02inning)
{
PlayerInning();
}
if (BallAIGameGoal)
{
BallGameGoal();
}
Player01EnergyToLive.fill01 = Player01liveEnergy;
Player02EnergyToLive.fill02 = Player02liveEnergy;
//Проверка на SpellDestroy
if (spelldestroy)
switch (NumberSpell)
{
case 0:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 1:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 2:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 3:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 4:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 5:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 6:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 7:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 8:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
case 9:
Debug.Log(NumberSpell);
spelldestroy = false;
break;
}
}
void PlayerInning() // метод обработки касания щитов игроков мячом
{
if (Player01inning)
{
Player01inning = true;
Player02inning = false;
//Debug.Log("Касание щита Первого игрока" + Player01inning);
}
if (Player02inning)
{
Player02inning = true;
Player01inning = false;
//Debug.Log("Касание щита Второго игрока" + Player01inning);
}
}
void BallGameGoal()
{
if (Player01liveEnergy <= 0f)
{
Player01liveEnergy = 0f;
}
if (Player02liveEnergy <= 0f)
{
Player02liveEnergy = 0f;
}
if (CoordinateBallXY > 0f & BallAIGameGoal)
{
Player01liveEnergy = Player01liveEnergy - .2f;
}
if (CoordinateBallXY < 0f & BallAIGameGoal)
{
Player02liveEnergy = Player02liveEnergy - .2f;
}
}
}
На всякий случай 3й. (Тут все работает)
using UnityEngine;
public class BalCollision : MonoBehaviour
{
public GameObject[] objects;
public GameObject[] ScorePrefabs;
public AIGame cudgel01;
public AIGame cudgel02;
public AIGame Player01;
public AIGame Player02;
void Awake()
{
Instantiate(objects[Random.Range(0, 9)]);
}
void OnTriggerEnter2D(Collider2D other)
{
// Debug.Log(cudgel01);
switch (other.gameObject.tag)
{
case "TheWith":
Destroy(other.gameObject);
Instantiate(objects[Random.Range(0, 9)]);
break;
case "TheBird":
Destroy(other.gameObject);
//Instantiate(ScorePrefabs[0]);
break;
case "cudgel01":
cudgel01.Player01inning = true;
cudgel02.Player02inning = false;
break;
case "cudgel02":
cudgel01.Player02inning = true;
cudgel02.Player01inning = false;
break;
}
}
}