- Home /
Write my code for me?
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; } }
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)
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.
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
}
}
}
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
Related Questions
FireBall script 1 Answer
I need help with my health script 2 Answers
How to cause damage on collision? 1 Answer
Health Regen Stop After Damage 1 Answer