Assets/Scripts/GameControll.cs(21,15): error CS0118: `UnityEngine.Object.Destroy(UnityEngine.Object, float)' is a `method' but a `type' was expected
My error
Assets/Scripts/GameControll.cs(21,15): error CS0118: UnityEngine.Object.Destroy(UnityEngine.Object, float)' is a
method' but a `type' was expected
GameControll Script;
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class GameControl : MonoBehaviour {
public static GameControl instance;
public GameObject GameOverText;
public bool GameOver = false;
// Use this for initialization
void Awake()
{
if (instance == null)
{
instance = this;
}
else if (instance != this)
{
new Destroy(GameObject);
}
}
// Update is called once per frame
void Update() {
}
public void PlaneDied()
{
GameOverText.SetActive (true);
GameOver = true;
}
}
My Plane/Player Script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Plane : MonoBehaviour {
public float upforce = 200f;
private bool isDead = false;
private Rigidbody2D rb2d;
private Animator anim;
// Use this for initialization
void Start ()
{
rb2d = GetComponent<Rigidbody2D> ();
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update()
{
if (isDead == false)
{
if (Input.GetMouseButtonDown(0))
{
rb2d.velocity = Vector2.zero;
rb2d.AddForce(new Vector2(0, upforce));
}
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
isDead = true;
anim.SetTrigger("Die");
GameControl.instance.PlaneDied ();
}
Your answer
Follow this Question
Related Questions
why the startcoroutine (spawnbigtree()); doesn't work and float don't work 0 Answers
i have a problem with StartCoroutine and float 0 Answers
Doodle Jump Game Platform Spawn Issue Unity2D 0 Answers
C#: How do you make a 2D game object jump? 1 Answer
How to make the camera stay the same size when changing resolution 1 Answer