Только начала изучать С# и наткнулась на пример, который не работает. Выдает ошибку "A namespace cannot directly contain members such a fields or methods". С помощью гугла определила, что это потому, что какой-то из методов не определен внутри класса, но я настолько начинающая, что не вижу, где ошибка в этом коде. Была бы признательна за любую помощь!
public class Jump : MonoBehaviour
{
public string levelName;
void Start ()
{
}
void Update()
{
}
}
void OnTriggerEnter(Collider other)
{
if (other.tag == 'Player')
other.transform.Translate(0, 5, 0);
}
Another unexpected cause of heap allocations can be found in the functions GameObject.name or GameObject.tag. Both of these are accessors that return new strings, which means that calling these functions will generate garbage. Caching the value may be useful, but in this case there is a related Unity function that we can use instead. To check a GameObject’s tag against a value without generating garbage, we can use GameObject.CompareTag().
[learn.unity.com/tutorial/…