Hi!
I have a simple project set up with a staticmesh and a sphere object for player location. It all works very well (thank you!!) except for a couple of things:
- When the sphere is on a sloped area of the staticmesh, it slides down hill ... as you'd expect. How do I control this? Is there a "stickiness" variable I can set for the sphere which will stop it sliding on surfaces with a shallow angle? (Edit: I found the material property while I was typing this but it's not acting quite how I expected).
- Gravity is a bit odd. I set it to -9.8f which caused the sphere to fall slowly, then -98f which caused it to fall faster then -980f which caused it to fall at a moderate rate. I was expecting the fall rate to increase to a terminal velocity (with air resistance?) or just keep increasing if no air resistance set.
- Bonus! Sorry forgot this for the title: how do I detect when the sphere is "settled" on a surface? I only want the player to be able to jump when on a surface for instance.
Thank you!
Collision sliding due to gravity issue (& gravity is weak?)
Re: Collision sliding due to gravity issue (& gravity is wea
How so? Keep in mind you can increase the friction values above 1 if you need more friction. The only requirement on friction values is that they are nonnegative. Increasing both StaticFriction and KineticFriction is more reliable than hoping an object will stay in static contact and only having high static friction.(Edit: I found the material property while I was typing this but it's not acting quite how I expected).
There is a very slight nonzero default entity.LinearDamping, but terminal velocity will be very high. Setting higher accelerations will always cause a faster fall. There's no complicated logic for a bug to sneak into; it's just linear velocity += gravity acceleration * dt.- Gravity is a bit odd. I set it to -9.8f which caused the sphere to fall slowly, then -98f which caused it to fall faster then -980f which caused it to fall at a moderate rate. I was expecting the fall rate to increase to a terminal velocity (with air resistance?) or just keep increasing if no air resistance set.
If you see what appears to be slower motion with higher gravity, it must be a separate interfering effect or an improper measurement.
One method would be to check the sphere's contact points and see if any of their positions are on the bottom of the sphere. You can traverse all contacts associated with an entity by looking at the entity.CollisionInformation.Pairs list and going through the Contacts list of each pair object.- Bonus! Sorry forgot this for the title: how do I detect when the sphere is "settled" on a surface? I only want the player to be able to jump when on a surface for instance.
If your goal is to make a character, it might be easier to just use the SimpleCharacterController or CharacterController instead. They handle the annoying stuff already. Information about what they do and the differences can be found here: http://www.bepuphysics.com/blog/2011/8/ ... tails.html
Re: Collision sliding due to gravity issue (& gravity is wea
Thank you - am going through the code now. Had a good play with all the simulations, very nicely put together. One question: when on a terrain (staticmesh) your character moves smoothly. Mine, when on my staticmesh terrain seems to jar across certain points (I think the boundaries between triangles). Any idea why this would be? I will try the CharacterController class on my terrain and see what happens, but I was wondering if you'd seen this before as when I was working on collision detection I found exactly the same thing (which is what prompted me to give up and look for libraries to use!) and am curious as to why it happens.If your goal is to make a character, it might be easier to just use the SimpleCharacterController or CharacterController instead. They handle the annoying stuff already. Information about what they do and the differences can be found here: http://www.bepuphysics.com/blog/2011/8/ ... tails.html
I was somewhat expecting valid values to be between 0.0 and 1.0. Still I had a play with putting extremely high values in (1000.0) and the character object still drifted! But, again, I shall go through the sample code, I am sure the answers are there, thank you!How so? Keep in mind you can increase the friction values above 1 if you need more friction. The only requirement on friction values is that they are nonnegative. Increasing both StaticFriction and KineticFriction is more reliable than hoping an object will stay in static contact and only having high static friction.
I assume by the way that the difference between static friction and kinetic friction is the friction when one/both of the objects are still and moving? In other words a surface with low kinetic friction but high static friction would mean objects kept sliding on it once they were moving but would require more force to start moving?
Re: Collision sliding due to gravity issue (& gravity is wea
That can be caused by a variety of things.Mine, when on my staticmesh terrain seems to jar across certain points (I think the boundaries between triangles). Any idea why this would be? I will try the CharacterController class on my terrain and see what happens, but I was wondering if you'd seen this before as when I was working on collision detection I found exactly the same thing (which is what prompted me to give up and look for libraries to use!) and am curious as to why it happens.
1) Scale issues may reduce numerical stability and lead to decreased robustness. If the involved objects are too big or too small, some collision algorithms will not be able to create quality contact data. Collision detection likes objects to have dimensions between 0.5 and 10 units. Going outside of the range some (particularly upward) is usually fine, but the farther you go, the higher the chance of problems becomes. Certain objects have special cases which avoid this fate, but it's still best to stay within recommended ranges. Rescaling the world to fit the ranges or tessellating collision meshes is sometimes necessary to address this.
2) Mesh has bad geometry. This can mean the mesh has duplicated geometry such as triangles in the same spot facing opposite directions, or degenerate triangles which have no area, or has particularly long almost-degenerate triangles which are bad enough to affect collision detection. Fixing the mesh is the best approach, but you can sometimes diagnose this by switching the mesh's sidedness from Counterclockwise to Clockwise and DoubleSided to see how the behavior changes or improves. This makes it easy to detect inconsistent winding and certain kinds of overlapping duplicate geometry.
3) A mesh's ImproveBoundaryBehavior is disabled (it is enabled by default). When enabled, this system smooths out normals at shared triangle vertices/edges to prevent bumps. Without it, objects can hit the sides of triangles. In order for this system to work, the mesh must have triangles which share features as defined by the index buffer. A 'triangle soup' mesh will not have its boundaries smoothed as it does not have connectivity information.
It is a common intuition, but recalling the physical meaning may make it more obvious. The maximum force of friction is coefficient * normal force. In reality, friction force can be higher than the normal force, so the coefficient must be able to be above 1. Some examples of such materials can be found on wikipedia: http://en.wikipedia.org/wiki/Friction#C ... f_frictionI was somewhat expecting valid values to be between 0.0 and 1.0.
Given that friction is purely a velocity effect, it is possible for drift to occur. However, in almost all situations, drift should not be visible. Some notable exceptions are in constantly accelerating situations, like in a big rotating room. Boxes will drift outward each frame since velocity is always a tangent to the circle and the update process takes discrete steps.Still I had a play with putting extremely high values in (1000.0) and the character object still drifted!
The non-simple CharacterController specifically addresses this by using a positional component to latch onto the ground when not walking. The same system could technically be built into the main friction model, but I'm not sure it's worth the expense

If you see drift outside of such 'odd' situations, it may be due to external interference.
Yes. A relative velocity at a contact point above a threshold forces kinetic friction to be used. Otherwise, static friction is used. It's a subtle effect though.I assume by the way that the difference between static friction and kinetic friction is the friction when one/both of the objects are still and moving? In other words a surface with low kinetic friction but high static friction would mean objects kept sliding on it once they were moving but would require more force to start moving?