- Home /
scripting a trigger to emit a healling effect on my character
hey everyone, i got this simple code that check and add some life points at the player life bar. I want to put a effect i´ve made with particle inside this IF when the player press the key E. How can I do that??
void OnTriggerStay(Collider other)
{
if (Input.GetKeyDown(KeyCode.E))
{
PlayerManager.health += 1;
Debug.Log("E key was pressed");
}
}
by the way, thanks for sharing with me your knowleged.
public GameObject $$anonymous$$yParticleEffect; //drag drop it here(parent it to character and disable it)
void OnTriggerStay(Collider other){ if(other.gameObject.tag =="$$anonymous$$yCharacter" && Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.E)){ Player$$anonymous$$anager.health +=1; $$anonymous$$yParticleEffect.SetActive(true); //you decide when and how particle effect stops //check on any way is the collider actually your character or else you will have some //other //collider entering the trigger and if player hits "E" it would activate the effect } }