I know the sound effects issue is going to be addressed in few videos from where i am, but this question of mine might not apply just for sound effects.
I added the enemy’s destruction sound effect to the enemyformation prefab, rather than the enemy unit prefab, and i’m trying to call the method OneLess() that is in the enemyformation.cs file from the alien.cs.
My main difficulty with C# so far has been around exactly that: dealing with and addressing objects.
Do you have a component on your object called enemyFormation? When you say “this”, you are saying that the component you are looking for is attached to the object that the alien.cs is a component of.
So I am trying to figure out exactly what you are trying to do. I know you are saying you are trying to call OneLess() from the enemyFormation.cs from alien.cs, I do get that. Did you declare it at the top and call it in the start function? For instance:
i’m getting this error message now, though (i copied exactly how you did it)
Assets/Entities/Enemies/alien1.cs(10,16): error CS0246: The type or namespace name `EnemyFormation’ could not be found. Are you missing a using directive or an assembly reference?
Ok 2 things on that… first, make sure you spelled it just like the object. Remember, code is very case sensitive. If you spelled it in all lower case, but call it with capital letters, won’t work. Second, make sure for a fact that enemyformation is actually in your scene
Use Capital letter for Class names (and the filename). Eg EnemyFormation. This will help distinguish from a variable which you’d start lowercase, eg enemyFormation
It might even be required…i’m not sure - but that’s the coding convention. My guess though is that’s why it can’t find it.