Hey everyone,
ok, I am working on a 2D Sidescroller. My character can swim. So I know when it is under water and when not.
Now I tried to instantiate a ParticleSystem when under water.
//Checks if the player is in Water
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Water")
{
isInWater = true;
anim.SetBool("inWater", isInWater);
rb2D.gravityScale = -0.01f;
rb2D.drag = 0.5f;
Instantiate(BubbleEmitter, transform.position, transform.rotation);
}
else
return;
}
//Checks if the player is ot of Water
void OnTriggerExit2D(Collider2D other)
{
if (other.tag == "Water")
{
rb2D.gravityScale = 1;
isInWater = false;
anim.SetBool("inWater", isInWater);
}
else
return;
Ok, now this Instantiates it as whished but it does not follow the player.
So I tried to set the parent. But I got the error message that I can not set the parent of a prefab.
How can I achieve this?
Thanks a lot for your help.