- Home /
Player health lose whenever player collide with object
Player health lose when player touch object only if the object is active. But didn't work somehow..
public class LaserFlickering : MonoBehaviour { public GameObject laser; public float delay; public float maxDelay;
void Update() { if (delay < maxDelay) { delay += Time.deltaTime; }
else
{
delay = 0;
laser.SetActive(!laser.activeSelf);
}
}
public void OnTriggerEnter2D(Collider2D col) { HealthControl.health -= 1; }
}
Answer by tormentoarmagedoom · Feb 22, 2020 at 03:17 PM
hello.
First, editt the code part, using the code assembler.
Second. when using ontriggerenter, need to make some kind of filter to decide which colliders will do the action. Now, all colliders in the game are activatong the healthControl.
Go google look for that.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Deactivate/Activate FPS Movement 0 Answers
Method doesn't work when called in other script 0 Answers
Weird gravity when enabling gravity OnTriggerEnter 0 Answers