- Home /
How to make enemy shoot a puddle that slows down player
I am making a top-down zombie game in Unity 2D and I want to make special zombies that spit a puddle on the ground that slows the player for a certain amount of time then disappears.
Any ideas on how to go about this? I can't find anything online.
Answer by Klarzahs · Oct 01, 2020 at 09:43 AM
Hi brax10h,
there are two parts to your answer: The vanishing and the slowing.
Vanishing: You can start a Coroutine that simply waits for x seconds and then deletes the Gameobject.
Slowing: You can use Colliders to see if the player is currently in/above a puddle and change the movementspeed
Hope that helps, happy programming
Thank you. I probably should have said I am new to program$$anonymous$$g, but my main concern is how to get the zombie to actually create the puddle.
Alright, then its a bit more longwinded. You'll need to decide the attack ti$$anonymous$$g of the zombies (at a certain range? every x seconds?) and target the player. Targetting can be easily done with the transform of the player (player.transform.position). You can then use GameObject.Instantiate to create a puddle object at the position. You'd have to either instantiate an already defined prefab, or you'd have to add a $$anonymous$$esh (aka the puddle model) as well, you can look into the $$anonymous$$eshFilter and $$anonymous$$eshRenderer Component for that
Your answer
![](https://koobas.hobune.stream/wayback/20220613012900im_/https://answers.unity.com/themes/thub/images/avi.jpg)