- Home /
Problems about prefabs and velocity affected by scripts
I am making a game which is similar to breakout but replacing blocks with different enemies. And now there are some problems. One of the problem is I combined the health bar, enemy and the scripts as one prefab. When I copy another one to the same scene, when I play it, only one of the health bar is deducted and another is not affected. How can I do to make them work separately? Another problem is that as it is 2D game. I use Physics 2D for the ball. But when the ball hits the walls or enemies, it will change direction horizontally or vertically but not like in 2D momentum. So to prevent this, I add script to make that when velocity of x or y direction becomes zero, the velocity will change. I set it will only after the ball is hit by the paddle because I want the ball will fall vertically at first. But when I play it, it does change velocity without touching the paddles. So how to fix these two problems? (I attached the a zip file in the bottom link for the whole project. The project is not much tidy. The scenes are in assets file, prefabs are in prefabs file and scripts are in fyp2 file.)
Your answer
![](https://koobas.hobune.stream/wayback/20220613141821im_/https://answers.unity.com/themes/thub/images/avi.jpg)