Unity3D Ball physics bug in BlockBreaker game 2D - unity3d

I am trying to create a block breaker game in Unity 3D but I am having problems (this is my first time creating a game). When I throw the ball it ends like this https://gfycat.com/LimitedVagueAnkole. The physics between the ball and the bricks should be problematic i think but I don't know why. My ball's material is frictionless and its bounciness is 1. My bricks materials are None (physics material).
I can send more info if it helps but I don't really know what else to send.
PS: I didn't code the breaking of the bricks yet. I just don't understand why the ball isn't acting the way it should.

The same thing is happening to me, I think I have a solution for this problem. I think the reason why the ball keeps bouncing at one place is because the ball didn't have much speed to escape from the loop. Try increasing the speed of the ball a bit and you could see the ball indeed escape bouncing at one particular angle.

Related

Setting up a sliding character in the right way

I would like to try and make a game similar to Altos Adventure. I am having trouble starting.
How to set up the terrain so that my character doesnt get stuck?
I simply drew a test sprite for the ground in photoshop. What collider2d should I use?
I use polygon collider and reduce friction in the material. But the character gets stuck, hits small invisible bumbs and it feels awful. The worst part is connecting 2 ground sprites together! The point where they connect is always messy.
I have a question for the future as well. How would I add the endless part of the game?
Would having many "pieces" set up and just spawning them as the player rides down work?
I havent written any code yet as the problem is simply in the physics in my opinion.
Thanks to anyone who takes the time and tries to help!
To move your player use rigid body.AddForce(Vector3 direction, ForceMode forceMode); then create a Physics Material with friction = 0 and put it in your player's collider.

Unity 2D box collider falls into another and than ports Playercollider upwards

I try to make my first Unity 2D game (it should end up to be a brawler) and i have a little problem with my colliders. My player collider straight falls a little bit into my scene colliders(the player starts ) and than the program realizes that this shouldn`t happen. It ports the player upwards. Now the player falls again and again he ports upwards. After 3 ports the player lands on the ground and can be used until he collides with another edge and than the same problem occures. I can even fly straight into the scene() collider itselfe sometimes i glitch out but sometimes i fall father down...
Can someone say me how to fix this?
Greetings and thanks for all answers
(BTW. I am sorry for my bad English i hope u can understand it)
You can play with Unity's physics 2D settings.
Most relevant to your problem seem to be:
Position Iterations (try to raise it)
Velocity Threshold (try to raise it)
Min Penetration For Penalty (try to lower it)
Baumgarte Scale (try to lower it)
A more accurate physic simulation is more expensive at runtime so try fixing your issue by tweeking just enough or your game will get slow.

swift usesPreciseCollisionDetection does not work?

i have made an app where you need to shoot on an enemy but sometimes the bullet goes through the enemy. swift sprite kit game when I shoot on a enemy sometimes the bullet goes trough the enemy, how can I fix this?
so i added usesPreciseCollisionDetection = true.
but the bullet sometimes still goes trough the enemy. so my question was did i do something wrong or is usesPreciseCollisionDetection not working?
thank you for reading my question I hope someone can help me.
You are using moveTo to move your bullets, Physics Engine does not work with moveTo the way you want it to, usesPreciseCollisionDetection will not do anything
As far as your Physics World is concerned, your bullet is stationary. You are just playing God and performing some kind of molecular transportation to move items.
You need to use functions like applyImpulse or even just give the physicsBody a velocity if you want this to work correctly
I had similar problem that is collision was sometimes not detected even when usesPreciseCollisionDetection was set to true and both SKPhysicsBody were rectangles. In my case usesPreciseCollisionDetection for some reason started working much better when I changed one of the SKPhysicsBody to circle instead of rectangle. Try changing your bullet physics body to circle, it seems that collision detection algorithm with circles is more precise so that might help you.

Unity Brick Breaker: Ball hitting in-between two bricks

I am making a 2D Brick Breaker game in Unity.
I have an issue with the scenario when ball hits in between two bricks. I have BoxCollider2D attached to all bricks and a CircleCollider2D attached to the ball. When the ball hits between 2 adjacent bricks, it bounces back in the same direction as if it hit the edge of the brick. There is no edge in between, but two adjacent bricks form a continuous surface. So, the ball should bounce off of the surface (in other direction) instead of bouncing back.
Anyone knows of any solution to tackle this problem? I asked this in the Unity Physics forums but didn't get any answer, so checking if anywhere here might have had this issue.
Thanks,
Mukul
I am guessing this could be the problem:
When your ball is hitting the bricks with a strong force, There is a chance it might move one of the bricks by a very very slight distance, even if the mass of the brick is much heavier.
This movement might cause an uneven surface, which is why the ball bounces back in the same direction.
Try adding a Rigidbody Component on every brick (if you have not done it already), and set its isKinematic property to true.
Let me know if this solves it.
Way 1:
Use one box collider for the wall, but not for every single brick.
This will fix your issue + will optimize your project.
Way 2:
You need to build wall programmaly and colliders in this case must be without spaces between them. This must fix the issue.
Way 3:
Make your own hitting wall logic.
OnColliderEnter you need to get balls velocity.
OnColliderEnd you need to set manually velocity.

How to change the shooting accuracy?

I am making an FPS game using unity 3d, I've a problem in the shooting accuracy script. Can you tell me how I can change it with a single script that shoot the bullet and include the shooting accuracy and equipped to the gun, please?
If you are currently using a raycast, you should have no problem.
If you are spawning a sphere and thrusting it forwards, I suggest you use a raycast.
Raycasts go in a completely straight line. Bullets follow gravity, and quickly fall to the ground.
You don't see bullets, they move too fast. Raycasts are invisible.
When it hits something, it sends you back the information you need. If you make the sphere go too fast, it might glitch through objects.
You can learn about raycasts here.