Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDamian Atlasik
1,320 PointsScoreCounter does not exist in current context
hello, i'm doing all like in videos and all went perfect until this part... have no typos, all is exactly like in video...
i tried deleting the ScoreCounter.cs and creating a new one but that didnt help. The new one is named ScoreCounterr.cs because after deleting the old one, i can't add one named just like the old one because it tells me there is already one named ScoreCounter.cs but when try adding it says that it don't exist...
FlyPickup.cs:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class FlyPickup : MonoBehaviour {
[SerializeField]
private GameObject pickupPrefab;
void OnTriggerEnter(Collider other)
{
// if the collider "other" is tagged with "Player"...
if (other.CompareTag("Player"))
{
// add the pick up particles.
Instantiate(pickupPrefab, transform.position, Quaternion.identity);
// ... decrement the total nr of flies.
FlySpawner.totalFlies--;
// ... update the score.
ScoreCounterr.score++; <---- here is where it don't want to accept the ScoreCounterr. code CS0103
Destroy(gameObject);
}
}
}
ScoreCounterr.cs
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngin.UI;
public class ScoreCounterr : MonoBehaviour {
public static int score;
private Text scoreCounterText;
// Use this for initialization
void Start()
{
score = 0;
scoreCounterText = GetComponent<scoreCounterText>();
}
// Update is called once per frame
void Update()
{
scoreCounterText.text = score + " Flies";
}
}
1 Answer
Max Gorbet
438 PointsYou spelled Counter in ScoreCounter with 2 r's
Quinton Gordon
10,985 PointsQuinton Gordon
10,985 PointsCan you please post a screen cap of your inspector for the Score?