В Unity 5, используя C# на линии 35 моего класса PlayerMovement У меня есть эта ошибка:Единство 5 Ссылка на объект необходим для не-статического поля, метода или ошибки собственности
Error CS0120 An object reference is required for the non-static field, method, or property 'GameManager.completeLevel()'
PlayerMovement Класс:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
public GameObject deathParticals;
public float moveSpeed;
private Vector3 spawn;
// Use this for initialization
void Start() {
spawn = transform.position;
moveSpeed = 5f;
}
// Update is called once per frame
void Update() {
transform.Translate(moveSpeed * Input.GetAxis("Horizontal") * Time.deltaTime, 0f, moveSpeed * Input.GetAxis("Vertical") * Time.deltaTime);
if (transform.position.y < -2)
{
Die();
}
}
void OnCollisionStay(Collision other)
{
if (other.transform.tag == "Enemy")
{
Die();
}
}
void OnTriggerEnter(Collider other)
{
if (other.transform.tag == "Goal")
{
GameManager.completeLevel();
}
}
void Die()
{
Instantiate(deathParticals, transform.position, Quaternion.identity);
transform.position = spawn;
}
}
GameManager Класс:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour {
public static int currentScore;
public static int highscore;
public static int currentLevel = 0;
public static int unlockedLevel;
public void completeLevel()
{
currentLevel += 1;
Application.LoadLevel(currentLevel);
}
}
Где вар г = новый GameManager(); ? –