The Falldamage has no effect on my healthBar when I collide from a distance of 20. here’s the script:
Ray GroundedTestRay;
RayCastHit Ground;
RayCastHit PlayerHit;
bool Grounded;
GroundedTestRay.origin = player.transform.position;
GroundedTestRay.direction = -player.transform.up // negative up so down dont forget -
physics.raycast(Ray, out Ground);
GroundedTestRay.origin = Ground.point + (-player.transform.up * .1); //start just under the ground to make sure there isn't any errors from beign so close
GroundedTestRay.direction = player.transform.position - Ground.point; //cast toward player
physics.raycast(GroundedTestRay, out PlayerHit);
if (vector3.distance (Ground.point, PlayerHit.point) > .1)
{
Grounded = false;
ApplyDamage = true;
}
float Timer;
bool TimerEnable;
bool ApplyDamage;
void Update()
{
if(TimerEnable)
{
Timer += time.deltatime;
}
If(!TimerEnable)
{
Timer = 0;
}
void FixedUpdate()
{
if (!Grounded)
{
TimerEnable = true;
}
if( Grounded)
{
TimerEnable = false;
}
if(Grounded && ApplyDamage)
{
if(timer > MinimumTimeToTakeDamage)
{
Damage = (PlayerHealthBar)target.GetComponent("PlayerHealthBar");
eh.AddjustCurrentHealth(-100);
}
}
}
It doen’st work.