Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 · timerdamageblinkinghealth

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 $$anonymous$$ching 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 $$anonymous$$ch, 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 $$anonymous$$asse.

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.Get$$anonymous$$ouseButtonDown(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
             }
         }
     }
 }

Follow this Question

Answers Answers and Comments

22 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

Related Questions

FireBall script 1 Answer

I need help with my health script 2 Answers

hi I know that this script is seen often but I have an another problem with a damage and health scripts. I think it's the GetComponent part, well anyway if you could help that would be great. 2 Answers

How to cause damage on collision? 1 Answer

Health Regen Stop After Damage 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges