• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by JeevanjotSingh · Nov 13, 2014 at 09:34 PM · rigidbodyplayerenemyballhealth

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)

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kiwasi · Nov 14, 2014 at 11:16 AM 0
Share

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.

avatar image JeevanjotSingh · Nov 16, 2014 at 06:50 PM 0
Share

Thanks Bored$$anonymous$$ormon for telling this to me in brief words (that's much easy to understand ins$$anonymous$$d unclear big answer )

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best 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

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JeevanjotSingh · Nov 14, 2014 at 10:28 AM 0
Share

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# .

avatar image DryTear · Nov 16, 2014 at 07:00 PM 0
Share
 public int damage = 5;
 void OnCollisionEnter(Collision col){
 if(col.transform.tag == "Player"){
 col.transform.GetComponent().health -= damage;
 }
 }


avatar image JeevanjotSingh · Nov 16, 2014 at 07:30 PM 0
Share

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?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Script Wont Take away health from my player when hit by enemy bullet. 0 Answers

Enemy not taking damage on collisions. 2 Answers

the code work bat is not push the ball but with speed of the character ? 2 Answers

I use this script, but the enemy lose health if i don´t target him. 1 Answer

Player Health 3 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges