- Home /
Damage script only works when moving
I have a script which causes my worm character to spin once when hit by an enemy projectile. However, he only spins if he is moving forwards, so if he is moving backwards or staying still there is no damage.
What could the problem be?
This is the damage part of my script, ask if you need to see the rest
if(gotHit)
{
if(tumbleSpeed <1)
{
//we're not hit anymore... reset and get back in the game
tumbleSpeed = backup[0];
decreaseTime = backup[1];
decayTime = backup[2];
gotHit = false;
} else
{
//we're hit, spin the guy around
transform.Rotate(0,tumbleSpeed * Time.deltaTime,0, Space.World);
tumbleSpeed = tumbleSpeed-decreaseTime;
decreaseTime += decayTime;
}
}
Thanks :)
cant really follow, because there is no full script here...
I guess it isnt supposed to rotate if worm is not moving or moving backwards...
i want to know what tumblespeed stores
How do you set tumbleSpeed? Is it a constant or something based on speed?
tumble speed is a variable, but yes it's constant. For some reason the script formatting will die when i paste it into the edit box, even though i use the pre-formatted thingy
Answer by G_Sacristan · May 29, 2011 at 02:37 PM
well i made something similar to this, but it worked not as i wanted it to, but this is a better way to do this... THX!
Your answer
Follow this Question
Related Questions
Damage script is messed up, how to fix 1 Answer
How to make a falling object cause damage? 1 Answer
Damage trigger? 1 Answer