- Home /
FireBall script
Hi everyone I am making a game in which you can use a series of magic spells and items. One of them is to be able to throw a fireBall which deals continues damage. I have used the "Launcher" weapon from the FPS tutorial but I can't seem to alter the script so that: 1. It does damage 2.The damage is continues upto a certain time limit.
I appreciat all anwsers right or wrong, thank you for reading this and thank you for your time and patience
That sounds like a forum question. Unity Answers is for questions with one clear answer and really game mechanics can be done any number of ways, mixing and matching scripts randomly will probably end up breaking another part of your game mechanics anyway.
Answer by Mike 3 · Jul 16, 2010 at 12:11 PM
In your collision method, store a reference to your player script from the colliding object (using GetComponent(PlayerScript), or whatever you called it). In that script, you'll want a damage function which just does health -= damage, and kills the player if the health is below 0 after
What you should then do, is call playerScript.Damage(initialDamage), and call a coroutine, something along the lines of this:
var tickLength = 1.0; var tickTime = 10.0; var tickDamage = 5.0;
function TickDamage(playerScript : PlayerScript) { var time = 0; while (time <= tickTime) { yield WaitForSeconds(tickLength); time += tickLength; playerScript.Damage(tickDamage); } }
That will apply damage (using the same function as the initial damage) to your player
Your answer
![](https://koobas.hobune.stream/wayback/20220613064936im_/https://answers.unity.com/themes/thub/images/avi.jpg)