Question by
TitaniumCats · Apr 01, 2019 at 08:56 PM ·
variableprogrammingtype
How can I define my own datatype?: `private EnemyCounter enemyCounter`
I have a really strange problem. I have written a script for a highscore detection. After a while i needed to make a var: private EnemyCount enemyCount;
I have copied a script from the official Unity side with this line and it doesnt worked. I cant find a solution anywhere else, it would be great if you can answer me :). Thanks.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class BulletController : MonoBehaviour {
private Transform bullet;
public float speed;
public EnemyCounter enemyCounter;
void Start () {
bullet = GetComponent<Transform> ();
enemyCounter.GetComponent<MenuScript>().MyFunction();
}
void Update()
{
bullet.position += Vector3.up * speed * Time.deltaTime;
if (bullet.position.y >= 1000)
{
Destroy(gameObject);
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Enemy")
{
Destroy(other.gameObject);
Destroy(gameObject);
enemyCounter = 1;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Trying to get doors to close after x time since the player has passed through the previous? 0 Answers
Why is the private int variable in this c# program not updating? 1 Answer
Why i can't use veriable as a type? 0 Answers
Saving and loading an int variable on Android 1 Answer
How to create a new variable type? 0 Answers