Остановка игры если ты умер.
Добавлено: 28 авг 2018, 10:04
Всем привет.
"Делаю смерть" в моей игре. решил, что все операции, связанные с остановкой игры надо вывести в отдельный скрипт "Stop".
Сделал GameObjectы Died и Stoper
На Died повесил скрипт "died"
а на Stoper "Stop"
в died указал Stoper и запустил.
Unity вывел такой лог ошибки:
UnassignedReferenceException: The variable Stoper of died has not been assigned.
You probably need to assign the Stoper variable of the died script in the inspector.
UnityEngine.GameObject.GetComponent[Stop] () (at C:/buildslave/unity/build/Runtime/Export/GameObject.bindings.cs:28)
died.Update () (at Assets/Scripts/died.cs:17)
Впрочем это всё.
Как исправить эту ошибку?
"Делаю смерть" в моей игре. решил, что все операции, связанные с остановкой игры надо вывести в отдельный скрипт "Stop".
Сделал GameObjectы Died и Stoper
На Died повесил скрипт "died"
Синтаксис:
Используется csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class died : MonoBehaviour {
public bool death;
public GameObject Stoper;
void Update()
{
if(death == true)
{
Stoper.GetComponent<Stop>().Stopped = true;
}
if(death == false)
{
Stoper.GetComponent<Stop>().Stopped = false;;
}
}
}
using System.Collections.Generic;
using UnityEngine;
public class died : MonoBehaviour {
public bool death;
public GameObject Stoper;
void Update()
{
if(death == true)
{
Stoper.GetComponent<Stop>().Stopped = true;
}
if(death == false)
{
Stoper.GetComponent<Stop>().Stopped = false;;
}
}
}
а на Stoper "Stop"
Синтаксис:
Используется csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Stop : MonoBehaviour {
public float timing;
public bool Stopped;
void Update()
{
Time.timeScale = timing;
if(Stopped == true)
{
timing = 0;
}
else if(Stopped == false)
{
timing = 1;
}
}
}
using System.Collections.Generic;
using UnityEngine;
public class Stop : MonoBehaviour {
public float timing;
public bool Stopped;
void Update()
{
Time.timeScale = timing;
if(Stopped == true)
{
timing = 0;
}
else if(Stopped == false)
{
timing = 1;
}
}
}
в died указал Stoper и запустил.
Unity вывел такой лог ошибки:
UnassignedReferenceException: The variable Stoper of died has not been assigned.
You probably need to assign the Stoper variable of the died script in the inspector.
UnityEngine.GameObject.GetComponent[Stop] () (at C:/buildslave/unity/build/Runtime/Export/GameObject.bindings.cs:28)
died.Update () (at Assets/Scripts/died.cs:17)
Впрочем это всё.
Как исправить эту ошибку?