• 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 /
This question was closed May 31, 2014 at 03:05 AM by meat5000 for the following reason:

Write my code for me?

avatar image
0
Question by Alvbatross_ · May 30, 2014 at 10:02 AM · timerhealthdamageblinking

How do you make your character take damage overtime if you don't blink?

ok another question from me, i'm still working on my weeping angels moving when blink animation occurs, but here is another question. I was able to make the character blink by using the right click. What I want to do now is have my character take damage overtime.

The point of my game is like slender, but this time with weeping angels. If the angels touch you you die. Now what I want is to have a timer that has for example 60 seconds, and when that timer ends my character starts taking damage. The only way to restart the timer is to blink by right clicking. Basically, if you dont activate the blink animation you die. here is my new blink animation #pragma strict

var appear : GameObject;

function Start() { appear = GameObject.Find("eye"); }

function Update() { if(Input.GetMouseButtonDown(0)) { renderer.enabled = true; } else { renderer.enabled = false; } }

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 meat5000 ♦ · May 31, 2014 at 02:20 AM 0
Share

Unity Answers is not for asking for solutions to vague problems or teaching Game Logic and Game Building/Structure/Concept. You need to be more specific with what you are trying to achieve in particular and the trouble you are having relating to specific parts of a script.

I need a script to... NO

I want a.... NO

Split your problem up in to smaller chunks and research them individually.

Use Google!

Taking damage is an extremely frequently asked question and so there are probably already a ton and half of answers here and around the net.

Do Tutorials!

We are not paid to teach, here. We are glad to help but Christ Almighty I think half the regulars are ready to cliffjump if they see one more Duplicate question from someone who seems to not know Google exists.

No offense but the answers are all there; En Masse.

Do Research! Ill say it again.

DO RESEARCH!!!

Oh yes, and format your code! (highlight and click 101010)

avatar image meat5000 ♦ · May 31, 2014 at 02:27 AM 0
Share

You can see if your animation is currently playing. I'll leave it to you to find out how, but that's how you do the Blink check.

http://lmgtfy.com/?q=unity+damage+over+time

Switching a renderer on and off doesn't count as animating, btw.

1 Reply

  • Sort: 
avatar image
0

Answer by wijesijp · May 30, 2014 at 11:31 AM

What you need to do is have a timer and start and reset it in those 2 stages

 #pragma strict
 
 var damageTimer : float;
 
 function Start () {
     appear = GameObject.Find("eye");
 }
 
 function Update () 
 {
     if(Input.GetMouseButtonDown(0)) 
     { 
         renderer.enabled = true; 
         damageTimer = 0;
     } 
     else 
     { 
         renderer.enabled = false; 
         damageTimer += Time.deltaTime;
 
         if (damageTimer > 60 )
         {
             // take damage
         }
 
     }
 }
Comment
Add comment · Show 1 · 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 Alvbatross_ · May 31, 2014 at 01:43 AM 0
Share

ok this time i added a timer for how long the game object "eye" will be rendered. it wont work but the damage timer works. #pragma strict

 var appear : GameObject;
 var damagetimer : float;
 var blinktimer : float;
 
 function Start()
 {
     appear = GameObject.Find("eye");
 }
 
 function Update()
 {
     if(Input.GetMouseButtonDown(1))
     {
         renderer.enabled = true;
         damagetimer = 0;
         blinktimer = 0;
         blinktimer += Time.deltaTime;
     }
     else
     {
        if(blinktimer > 3);
         {
             renderer.enabled = false;
             damagetimer += Time.deltaTime;
         
             if(damagetimer > 60)
             {
                 //take damage
             }
         }
     }
 }

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

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Subtract one from health every five seconds. 1 Answer

Health and Damage System Help 1 Answer

Player taking damage on collision. Can't get the script to work!? 1 Answer

Calling a variable from one script to another 1 Answer

How do I destroy a game object (The enemy Goblin Game Object) upon entering a collision box? (JavaScript) 2 Answers

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