- Home /
Water Question
I was wondering how could I add a script to allow when you go underwater to deduct 5 health every 10 seconds you are under. How could I go about doing that?
you could have a trigger as the water and then test to see when the head collider enters it, and then deduct the amount every 10 seconds
I have a Box Collider over water, umm....but I'm not sure what you mean about the trigger. And like the other thing.
Whoever decided to give the negative vote, at least you could leave a reason as to why, ins$$anonymous$$d of a hit-and-run affecting the OP. Sure, it may seem like a noob question to you, but you don't know the age or experience of the OP, nor have you provided any constructive critizm or advice. How about showing yourself and explaining why.
i never give negative votes as most of my questions are silly, which if i wasnt so tired would of worked out, i gave plus 1 to get rid of it
infact i know someone started gving me thumbs down on some of my older questions, some people are just douches
Answer by AlucardJay · Aug 22, 2012 at 03:32 PM
I shall start from the beginning to help explain the process you need to follow.
I'll be using video links to help you see the concepts working.
Using Triggers and OnTriggerEnter :
Beginner B13 - Trigger Collision Detection
http://www.unity3dstudent.com/2010/07/beginner-b13-trigger-collision-detection/
Note how setting the trigger to True (tick), and setting the Mesh Renderer to False (Untick), you can create a 'zone' that you can place where you want the trigger to occur.
Also , and probably most Importantly , read the Unity Scripting Reference on the commands you want to use :
http://unity3d.com/support/documentation/ScriptReference/Collider.OnTriggerEnter.html
Here is the link to other video's in the beginner set by Unity3Dstudent :
http://www.unity3dstudent.com/category/modules/beginner/
If you watch these and are still having trouble, I am happy to help you edit your scripts to get the effect you are after.
Please ignore the -1 vote to you. Some people find it hard to understand we were all noobs once. Keep asking questions (as long as they're reasonable) and you'll find nearly all of the other members of this 'site are friendly and helpful.
In regard to asking questions, have a quick look at these links :
the FAQ appears at the top of the page : http://answers.unity3d.com/page/faq.html
also : http://answers.unity3d.com/questions/133869/how-to-ask-a-good-question.html
Abbreviated from my answer here : http://answers.unity3d.com/questions/240136/sliding-door-animation-question.html
I will look into this as soon as I can and will let you know what happens. Thanks!
Answer by MaT227 · Aug 22, 2012 at 04:07 PM
If your water is always at the same Y you could have like : When my object position is under Y you launch a counter that will decrease your life by 5.
Else, You need to put triggers and check ontriggerenter.
Your answer
![](https://koobas.hobune.stream/wayback/20220613080019im_/https://answers.unity.com/themes/thub/images/avi.jpg)