Hi Nevik,
One of your issues is here;
Projectile.cs
void Start()
{
killedEnemys = Gameobject.Find(KilledEnemys).GetComponent<LevelManager>();
}
What you are saying there is “Find me the GameObject called KilledEnemys, and then get a reference to a component attached to it named LevelManager”.
Where-as actually its the LevelManager GameObject you want to find, and killedEnemys
is not a component, but a member variable of the LevelManager class.
void Start()
{
levelManager = GameObject.FindObjectOfType<LevelManager>();
killedEnemys = levelManager.KilledEnemys;
}
There are a number of things I might suggest changing with your approach, but perhaps initially, just get it to do what you want it to do and then consider improving it afterwards.
Not least of which is having this find operation on every projectile, find is quite expensive from a performance perspective, so having something run off to find the same thing ever time a projectile is created isn’t ideal. But one thing at a time. See what happens with the above changes.
Hope this helps.
Also, please copy/paste your code into your posts and apply code formatting (see below) rather than using screenshots, it is much more difficult for people to help you with screenshots as they have to type out all of the code themselves when making suggestions, rather than just copy/pasting part of your code back to you in a reply.
Screenshots are really useful for details from the Unity editor or errors though.
See also;