Unity3d - Player flips after a specific chunk - unity3d

So, I've made a very simple game, which all you basically do is glide through the terrain and avoid the obstacles (I haven't implemented obstacles yet). And I've encountered a very strange problem. When ever I hit the fifth chunk, the player starts to flip:
Can anybody help me find what the problem is and how can I fix it?
Edit: I solved it by using creating a physics material with 0 friction annd applied it to both the chunk and the player.

This could be an issue with your colliders being just a tad too big. check the dimensions of your player's box collider and see if it is bigger than your player. If so make it fit to just inside the outer edges of the player box. Also, unless you ever plan to flip the player intentionally, You could always just apply a constant downward force (Rigidbody + gravity usually will suffice) to keep this from happening. Hope that helps!

Related

Objects not colliding Unity2D

I am trying to make a Retro Tenis Game in Unity2D but I have some issues with the colliding system.
My controller does not collide with the walls. It goes through them.
It should stop in the wall like pic1 but it goes through it like pic2.
Can anyone help me, please?
pic1
pic2
UPDATE#1: I added a RigidBody component but it does not fix it. (pic3)
pic3
You shouldn't use the colliding system for this purpose. It would be much better that the script in charge of moving your paddle was able to control its maximum and minimum height too (note that the screen size can change, and the paddles should move at different heights depending on the screen size).
Although if you want to do it with the collision system and "walls" that limit the space of the paddles, both the "walls" and the paddles need to have a correctly positioned BoxCollider2D and the paddles an extra kinematic Rigidbody2D too (as they can move).
Also make sure to move the paddles using physics and not modifying its position with transform.position (see Rigidbody2D.MovePosition)
Edit: Unity2D physics system is rather a complicated topic and difficult to get it well on your own. I'd suggest to learn the basics in the Unity Learning Platform. You could start with this project.
You need add RigidBody2D to your "circle"

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.

Very weird position "snapping" with simple box colliders?

Im not even sure what is happening here but I'm just trying to make objects fall normally onto the floor - they need gravity/be able to be pushed around, but just fall onto a static floor object.
I have a cube and my floor mesh. Floor mesh has this:
Cube has this:
Initially I'll have my cube just positioned right over the floor. Then I press play and pause, within one second it's 100 m away, spinning/falling. What could be happening here?
You may face problems with small size colliders due to how the physics engine works. Increase size of colliders and see if it helps. If you really need colliders this small, try changing the Default Contact Offset in Physics Manager.

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.

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.