Floor affects ball force direction - unity3d

I'm creating a pool game. The ball has a trajectory direction and I move the ball using AddForce. My problem right now is if the ball is touching the floor it's direction will go a little offcourse while if it doesn't touch the floor the direction is pretty accurate. What can be the cause of this? Btw, I have set the angular drag and drag to 0 same as friction

Make sure the floor is using a box collider and not a mesh collider, in case maybe the mesh has some deformities. Check the same for the billiard balls that they are using sphere colliders. It also sounds like maybe the floor could be at a slight angle, so be sure to check the rotation of its GameObject as well as all its parents in the hierarchy.

Related

How to make that 2d collider dont slide on on an inclined plane

If 2d collider with rigidbody with freezed Z rotation touches an inclined plane with its lower edge, then it begins to slide down, how to get rid of this effect? I want if rigidbody edge touch the inclined plane, rigidbody should keep his own position and dont slide down.
I agree with BugFinder, a frozen rotation on a Rigidbody will not affect the interaction between the collider and the inclined plane. You should create a new PhysicsMaterial and assign it to your Collider that is assigned to your Rigidbody. Increase either its staticFriction, dynamicFriction, or both, as well as experimenting with the frictionCombine option, which will change how the friction value of your Rigidbody will interact with the collider of the inclined plane.

Ball moving in tube with rigidbody

Lets say you have a sphere(rigidbody, sphere collider) inside a tube(mesh collider). I want a ball to move in the direction of tube always by applying force on rigidbody.
My purpose is to simulate the circular gravity, so that ball can fall down back obviously in circular motion. This was the approch i was using to simulate fake circular gravity.
How can I check which direction of force has to be applied to continue motion following the path of the tube with addforce?
try applying physics material to your tube to control the ball reaction to the surface of the tube.

Two Colliders overlap a little bit each other in Unity

After coding left and right movement of player which had BoxCollider and Rigidbody, An serious problem happened. when player moved toward an cube which had BoxCollider, player's collider overlapped with the cube by 0.02. Please tell me how to fix this problem.
For your information, the movement that I made was by rigidbody.MovePosition in FixedUpdate. And I already set collision detection to continuous. Also, I set the friction to zero with Physics Material.
When player don't move, the x Position is 2.525 enter image description here
But when player move, the x Position is 2.545 enter image description here
Colliders overlap - it's how collision detection works. If the overlap is too great, you can make one or both of them bigger, make the physics settings tighter, or some combination of these. Note that the amount of overlap is also affected by the speed of the objects - the more speed, the more potential overlap. What you can't do is expect PhysX to work with no collider overlap.

Preventing collider from glitching through terrain

I'm using a terrain in Unity 2019.2.1f1 and a custom mesh of a cave with a mesh collider.
My character that has a Capsule Collider way bigger than the entry of the cave should not be able to enter in. But due to the roundness of both colliders, he can come into force in the cave, glitching through the terrain collider.
I think it's velocity is not excessive, I'm moving the character with rb.MovePosition() in the FixedUpdate(), and I set its rigidbody collision detection to Continuous speculative (tried all the "continuous" modes)
In the animation below, you can see the mesh of the cave and the capsule collider around the character.
How can I prevent this from happening? How can I say to Unity: "I want the colliders to be rock solid and not marshmallow"?
Colliders in Unity are rock-solid. They are incapable of any kind of soft physics, and the only moment they will warp through each other is when you force them to.
Here, you are setting the rigidBody position by force, into an impossible location. The game tries its best to fit your rigidBody despite the lack of room.
You can
Only use forces, and velocities. You can simply set the velocity to the direction of your choosing, and set it to 0 when you stop moving, or use AddForce, which is basically the same thing.
Keep using MovePosition, but use a SphereCast or CapsuleCast to check if you have enough room to move first.

Sprite Kit physicsBody loses consistency during rotation - zrotation

I have this classic situation of a pinball game
All objects are physicsBody with rights collision masks and so on.. they collide perfectly.
The problem is that they only work when they are static...If I try to rotate a paddle on its anchorpoint, there is no collision with the ball and the ball falls down, passing through the paddle.
I thought it was a problem of speed but I think that during the rotation the physicsBody simply doesn't work.
Do you have suggestions?
Thank you so much.
That's exactly the problem you get when rotating a static body, it's not going to act physically correct.
For example static bodies have no force, no velocity - if you move or rotate it, it will just be there at the new position and new rotation without pushing any dynamic bodies around. Only if a dynamic body now happens to be intersecting with the static body will the physics engine try to resolve the collision, usually in a brute-force manner (aka "get me outta here").
Therefore the paddle has to be dynamic if you want it to move, accelerate and spin the ball. Both paddle and ball may need to have continuous collision detection enabled as to not lose any precision in the paddle motion applied to the ball, and vice versa.