Spherical rigid body will never stop rolling regardless of drag - unity3d

My problem is that I have a rigid body with a spherical collider and once it starts moving (rolling) it never stops.
I have read other answers here which state that changing the drag (angular and normal) is the answer to this problem but I must be doing something wrong somewhere else. I have been experimenting with this for hours and cant find a solution.
I have moved the drag to a million, still moves but very very slowly. I have moved the angular drag to a million with similar results. I have set the sleepThreshold to a high number. This didnt seem to do anything. I tried changing the friction on the terrain.
I placed the ball on a flat, horizontal plane for all of these tests and applied an impulse to start it moving. It has never come to a stop yet.
There are times when it reaches a certain velocity and then stutters like it is about to stop and then it starts moving at a constant velocity forever, I think I can visibly observe the shift from deceleration to constant velocity. It doesnt make any sense to me at all.
It is my assumption that the ball should stop eventually and that unity, being so advanced, would handle this easily but its possible that I'm missing something due to being so new.

Related

How can I stop movement while airborne?

I have recently begun working on a game for a uni project and will visit this site probably a lot while encountering problems. This time it's a small but annoying problem.
I am doing a 2D sidecroller so I used the template for it to get me started. I already put in the input for attacking and want that the character stops moving when he does the attack animation. On the ground it works wonderfully, but while airborne the character doesn't completely stop in the air, but is slowly decending during the animation. And I want that the character stops completely.
Here is the Jump Handling from the 2d sidescroller template.
Here is the event tick and where the animation update is called (Ignore the attack counter stuff, doesn't influence)
Here is the Animation update code and the "Stop Movement Immediately" node. It has to be said that I am doing what I learned from a tutorial.
As the name implies, the node should stop movement, which is does in the X Axis, but not completely in the Z Axis. I tried it by saving the location of the Player Character when he attacks while in the air but either I couldn't get the code right or it doesn't work like that.
I would be thankful for advice with this (rather petty) detail.
If your problem is strictly while falling, try setting the gravity to 0 while attacking, create an Event in the animation that fires up when it's finished and then capture it to set the gravity back to the original value.

Unity ball friction either too much or not enough

So i am making a simple Golf game, when trying to replicate the balls movement i have noticed that on slopes the ball functions very oddly, it either never stops or stops too quickly and when travelling down slopes will reach a very slow terminal velocity quickly (ie it stops accelerating down slopes). So it either doesnt deaccelerate enough going up a slope or accelerates too slowly going down a slope.
I have been messing about with angular and static Friction of both the ball and the surface to see if that changes it at all and i have also been changing the friction combine of the surface and the ball to see if that makes any difference and so far haven't had any luck.
Is this a common issue with Unity because i haven't been able to find any other questions about it on here. If anyone could give me some advice on how to have my ball not roll forever but still accelerate when going down a slope that would be great
EDIT: The ball has a rigidbody with continous collision, then the course uses a mesh collider. Both however have attached physics materials
The ball is currently just a basic sphere from unity using a sphere collider, i havent tried changing the rigidbody about much yet other than mass. When the ball is hit i addforce to it, the slopes are an asset i have purchased that are perfectly smooth.
Rolling object physics are indeed difficult in game engines.
As I mention in the comment for such questions it's necessary to know (a) what sort of collider and (b) what sort of object it is, since there are at least 4 major approaches to this problem.
But in general you usually have to manually add the "slowing down" function, in a sense representing air resistance.
For a moment set aside the collider choices, and imagine in the abstract you have a ball rolling along a flat plane. You've somehow started it moving at 2 m/s say.
There's really no reason at all it will stop rolling or slow down. Why would it? There's no air resistance in physX and what you "want" it to do in the game engine physics is keep rolling.
Thus what you do is add a script that, essentially, "slows it down a little" every frame. In pseudocode, something like
velocity = 0.99 * velocity
Note however that alternately, to "manually slow it down", you may have to simply add force to it.
The trick is you do that in the opposite direction to movement
yourBalls.addForce( v.normalized * -1 * some small force )
(It's easy to think of that as basically "air resistance")
You usually also, simply, just add a top speed. In this way on downslopes it won't just get "infinitely fast"
if (v.magnitude > 3.0) v = v.normalized * 3.0
That's basically how you make objects roll around on hilly surfaces.
Note that you basically should not fool with the friction settings in anyway, it's really not relevant in most cases.
Unfortunately there is a vast amount of detail but, I feel your question is more asking for the "basic principles" - and there they are!
Tip: it could be this question is more suited to the gameDev site, where "techniques" of game physics are QA'd.

(Unity 3D C#) Conveyor Physics

So, i am trying to create a flat conveyor that a block will sit on and move, but i want to have it be able to turn, so i cant use rigidbody.moveposition, ive tried using addforce, but i cant get it to work properly without using impule or velocity change, because then it makes the ore roll (they are cubes). my most recent attempt was using velocity, but im not sure how to make it keep its old velocity when changing corners so it doesnt screw it up.
.
If this doesn't make much sense, here is a better explanation, i am trying to create a conveyor system on a grid, where each slot has a direction, and an cube travels along it, whenever the cube reaches a turn, i want the cube to keep moving forward a short distance so it doesn't just immediately change directions and go along the new conveyor, because this way, it will immediately change and will sit on the edge of the conveyor, and not keep moving in the direction.
edit: i currently have it working, my now issue is the cubes will bounce when touching the conveyor, so they wont stay flat against the conveyor, i can fix this by constricting all the cube rotation, but then it will sometimes freeze the ore on the conveyor, not allowing it to move.
since you didn't provide code, I don't know what you are trying to do, so I will give my own solution:
object.transform.position = Vector3.MoveTowards(target.transform.position, endpoint.position, Time.deltaTime * speed)
Then, when it collides with it, it can turn off this script, so it stays at the end.
target is what you want to move, endpoint is where you want it to end up.
Make endpoint a gameObject, and put it at the end of your conveyor, so the objects will move toward, and it will look like a conveyer.

remove bouncing from PhysicsBody?

How can I completely remove the bounciness from my PhysicsBodies, I already set the restitution of all PhysicsBodies to 0 but when multiple PhysicsBodies collide they still bounce off of each other, how can turn this off?
Here's a video where i swipe up and down which triggers this code on the blue SpriteNodes:
node.physicsBody?.applyImpulse(CGVector(dx: x, dy: y))
https://imgur.com/a/MD2Sc
I want the blue SpriteNodes to just stay up or down and not bounce away
Are you experimenting in a space without any world damping/friction? If so, you will need to zero the velocity of objects the moment they collide in order to get zero bounce. But you'll also need to move them outside the boundary of the objects they collided with.
By way of explanation:
This is, I presume, happening because your objects are achieving a (slight) state of overlap right before the collision is reported to the physics engine. When this happens, the first response of some physics engines is to remove this overlap by moving the object with a corrective amount of force or movement. What's happening looks like a continuation of that movement.
In some physics engines you get the opportunity to determine how strongly the corrective behaviour is, and how frequently it occurs, and even set the physics simulation to much higher rates of solving than the frame rate. In these engines you could find the right balance of settings to prevent this. But not in SpriteKit.

Character Pawn sliding back when picking up objects

I am using Unreal Engine to create a puzzle game. In this game, the player has to pick up a chair/table and place it on a pressure plate in another part of the room in order to unlock a door.
When play testing, picking up objects causes my character to slide back. Once the sliding starts, there is no way to make the character stop sliding. I suspect that this issue may be caused by the object's collision volume entering the character's. However, when I release the object, my character keeps gliding backwards even though by then, the object's collision volume is out of reach.
On my character's blueprint I have locked rotation on all axes, so that it won't randomly start rolling backwards after picking up an object. This solves part of the issue but there is still the gliding that just won't stop.
I am new to UE and I have no idea what may be causing this issue. If you have any previous experience in this or simply want to chime in, please do!
Another alternative fix is to lock the rotation of the collision component in the default pawn that you have or to increase angular damping.
To do so, open the default pawn blueprint and under the physics section, then constraints, lock rotation in the X, Y, and Z axis. Or increase angular damping.
Dont know why this is happening exactly unless we see the actual settings you are using and the BP but when you pick up the object , disable its physics and collision and when you put it back enable it after a delay of 0.5 or 1 second . Hope this helps.