Hey, I’m a real newbie in Unity2d and my question is how can i make a sprite(Ball) move across the screen like
? I added sprites to the side of the wall and colliders too. My problem is that when i run the game the ball just bounces up and down and nothing else.
Thanks!
If im not incorrect maybe you could add a physics material and a rigidbody to it, then choose the bouncy one, and they should bounce all over the place.
I tried it, it’s bouncing only Up and Down
They only go up and down because of gravity.
Try setting gravity to zero on the rigidbody and using AddForce to move them.
When they collide with a wall, have them pick a random direction in a 180 degree radius that is opposite from where it hit (I.E. if it hits at 90 degrees, addforce to a random degree between 270 and 360)
If they all have colliders on them, hitting each other should already be handled by the physics system.
^ Thanks! I got a new problem, sometimes the ball hits the wall(collider) perpendicularly, this causes the ball to bounce back and forth in a straight line. What code should i write so that whenever it’s like this then change angle or ball.
Another Problem, How do i increase the speed of the ball while in-game? I tried making tweaks to the mass in-game but it doesn’t make a different