I have two spheres named projectile and projectile2 and they are located in a folder names Resources(they are prefabs).
I have an enemy that if it gets shot with projectile it loses 2 point and if it gets shot with projectile2 it loses 5 points. The thing is that im using gameObject.name but when the cube gets hit by any of the two spheres no collision is detected. Am i suppose to load the sphere somehow since they are located in the hierarchy but in a folder a different folder??
When the projectile hits the target, it calls a “DoDamage(float amount)” function on the thing it hit (the thing being hit will need that function to handle the damage it is being dealt)… you can then have 1 prefab and assign the different damages through inspector values.
oh and try to never us “name” as a differentiator, instantiated objects often get “(clone)” or whatever added. Tags or checking for specific components with GetComponet is far better.
a okay cool and yeah the Decrease health already handles that. The the thing is no collision is being detected if you notice the Debug.line Does not even print in the console so enemy is not detecting it being hit by a projectile and okay cool ill look up “clone” and GetComponent
Your projectiles names are probably being renamed at runtime to something like “Projectile2 (Clone)” or something like it, so using the name tests for objects that get instantiated at runtime may not be a good idea.