Hi everyone,
Ive ran into this one complier error and cant seem to find a fix does anyone know what i did wrong?
#pragma strict
var winner ; AudioClip;
function OnTriggerEnter () {
GetComponent.().PlayOneShot(winner);
}
Hi everyone,
Ive ran into this one complier error and cant seem to find a fix does anyone know what i did wrong?
#pragma strict
var winner ; AudioClip;
function OnTriggerEnter () {
GetComponent.().PlayOneShot(winner);
}
GetComponent is for getting a component, it needs to know what it’s trying to get.
Firstly, you need an AudioSource.
Secondly, make it say
GetComponent.<AudioSource>().PlayOneShot(winner);
It would really help if you formatted your code properly using the 101010 button and also included the full error message which tells you the line number on which the error lies. But, from the looks of it:
var winner ; AudioClip;
Should be:
var winner : AudioClip;