Почему скрипт не работает? Vector 3
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Slime : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
GameObject Archer = GameObject.FindWithTag("Archer");
Transform bober = Archer.transform;
}
// Update is called once per frame
void Update()
{
float distance = Vector3.Distance(transform.position, bober.position);
Debug.Log(distance);
}
}
Ответы (1 шт):
Автор решения: Алексей Шиманский
→ Ссылка
Transform bober надо бхявить как свойство класса, а в методе Start писать уже просто:
bober = Archer.transform;
В ином случае получается, что ты объявляешь переменную в одном методе, а использовать пытаешься в другом
