- Home /
Need Help About Health,Damage
Hi I need some simple help as a newbie . I am developing my first game and i need help that My player is a ball(like roll-a-ball tutorial player) and i want to assign that ball health . and i also have enemy who always follow my player and i want when i touch to my player something like a ... boom ... particles and my player decrease some health (Is there any link of assets store particles that help me with this)
I need in c# please help me guys .
and one more thing ... i will make my game commercial if it will complete so is there any issue if i use assets store free assets .(Please answer this question in brief yes/no because it's not a big deal for me , the bigger problem is player health system Please help me there)
On the commercialisation front you are free to use any assets you purchase from the asset store in a game. Even if they are free. Its laid out pretty clear in the EULA.
Thanks Bored$$anonymous$$ormon for telling this to me in brief words (that's much easy to understand ins$$anonymous$$d unclear big answer )
Answer by IEMatrixGuy · Nov 14, 2014 at 04:04 AM
Hi,
What you want is the OnCollisionEnter() function. This checks when you collide with something, and then you can tag the enemy as an enemy in the inspector and check the tag ith collider.compareTag("enemy");
http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter.html
If it is the enemy, just remove some amount of health from your player health variable.
As far as particle effects go, you could use a particle system and just enable and disable it again. The system itself can be configured in the inspector.
As to publishing your game, I would personally only make it commercial, if all the assets are yours, and the game idea is yours (i.e not a tutorial) just to make sure there are no copyright problems. But a ball shouldn't be too hard to model and texture yourself. :)
Good Luck,
Hope that helps :)
IEMatrixGuy
Hi, Can you please tell me how can i decrease player health in enemy script . Like first i add my script **public int health = 100;**
now how can i access health to decrease in my another enemy script in c# .
public int damage = 5;
void OnCollisionEnter(Collision col){
if(col.transform.tag == "Player"){
col.transform.GetComponent().health -= damage;
}
}
Thanks for comment and really helpful but it will Giving me error for getting component from another script (i mean i am a newbie so i will add that line and check it ouy if it will work ) Thanks again for help .
I got error that health is not existing in the component after http://unity3d.com/learn/tutorials/modules/beginner/scripting/getcomponent using this tutorial and the script . Any Idea?