- Home /
This question was
closed Aug 07, 2017 at 08:52 PM by
FortisVenaliter for the following reason:
Question has been answered many, many times.
Question by
NetSuprime · Aug 07, 2017 at 06:11 PM ·
c#2dscripting problemfast
Assets/Scripts/GameControll.cs(21,15): error CS0118: `UnityEngine.Object.Destroy(UnityEngine.Object, float)' is a `method' but a `type' was expected
My error message:
Assets/Scripts/GameControll.cs(21,15): error CS0118: UnityEngine.Object.Destroy(UnityEngine.Object, float)' is a
method' but a `type' was expected
My 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;
}
}
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 ();
}
}
im new to scripting so please make it understandable for a beginner thanks!
Comment