Не могу понять - почему у меня обнуляется Vector3 _spownPos.
В Start он задается нормально и выдает правильные значения, а в самом void Create_archer() - обнуляется (
В чем моя ошибка?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
public class Army : MonoBehaviourPun
{
[Header("Cost")]
private int _archerCost = 10;
private int _preastCost = 10;
private int _shieldCost = 10;
private int _spearCost = 10;
private int _swordCost = 10;
public GameObject _archerPrefab;
public GameObject _shieldPrefab;
public GameObject _preastPrefab;
public GameObject _spearPrefab;
public GameObject _swordPrefab;
public Transform _army;
private TokenCounter _tokenCounter;
private GameObject _healthbar;
public float _hp = 0f;
public int _amount = 0;
public List<GameObject> _soldiers = new List<GameObject>();
private Vector3 _spownPos;
private void Start()
{
_tokenCounter = GameObject.FindGameObjectWithTag("Token counter").GetComponent<TokenCounter>();
_healthbar = GameObject.FindGameObjectWithTag("Healthbar");
GameObject[] _spownPos_s = GameObject.FindGameObjectsWithTag("Spown");
for (int i = 0; i < _spownPos_s.Length; i++)
{
if (_spownPos_s[i].GetPhotonView().IsMine)
{
_spownPos = _spownPos_s[i].transform.position;
Debug.Log(string.Format("Позиция создания = {0}", _spownPos));
}
}
Debug.Log(string.Format("Позиция создания 2 = {0}", _spownPos));
}
private void Update()
{
}
//Проверка PhotonNetwork.Instantiate
public void Create_archer ()
{
Debug.Log(string.Format("Позиция создания 3 = {0}", _spownPos));
if (_tokenCounter._tokens >= _archerCost)
{
GameObject _newSoldier = PhotonNetwork.Instantiate(_archerPrefab.name, _spownPos, Quaternion.identity);
_soldiers.Add(_newSoldier);
ArcherScript _soldier = _newSoldier.GetComponent<ArcherScript>();
}
}
}