❔ An Error I can't figure out
using UnityEngine;
using UnityEngine.UI;
public class Ball_Controller : MonoBehaviour
{
private Rigidbody2D rb;
public Text leaderboardLabel;
public int score = 0;
public GameObject ball;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
rb.velocity = new Vector2 (3f, 3f);
ball = GameObject.Find("Ball");
}
private void OnCollisionEnter2D(Collision other)
{
if (other.gameObject.CompareTag("Paddle"))
{
score++;
}
}
There's an error with the public text variable.
It says that "the type or namespace "Text" could not be found" Although I have been following a tutorial
6 Replies
When you fully qualify
Text
like this UnityEngine.UI.Text
does it compile?$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/Shouldn't matter as the namespace is already defined in usings
I didn't notice it actually
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.