TrueSync 3D collision resolution makes character "float" on the ground.

Hello,

I have the problem that the 3D collision detection with TrueSync's Physics does not work like I intend to. In Unity, when I set the bounciness of the physical materials to zero and jump with a character onto a platform, the character will just "snap" to the ground of the platform without bouncing up or down. And after that, I can move on the platform with the feet of the character perfectly aligned on the surface of the platform.

With TrueSync, it is often the case that the character phases through the platform or bounces strangely on the surface of the platform. Note that it is not a problem that collision is not detected. It is in every of my use cases, it is just the way the PhysicsWorld resolves these collisions. I played with the TSMaterial parameters, but changing friction or restitution does not yield the results I hoped for.

Is there a way for me to place the feet of the character directly on the surface of the platform without having the character bounding up/down on the platform?

I don't care if Photon is discontinuing 3D Physic support for the future versions, I would like to know if it is possible with the current implementation.

I've seen that TrueSync uses Jitter physics. And there is a thing called "Speculative contacts" which seems like it could be the solution for my problem:
https://github.com/mattleibow/jitterphysics/wiki/Speculative-Contacts
https://wildbunny.co.uk/blog/2011/03/25/speculative-contacts-an-continuous-collision-engine-approach-part-1/


So, has anyone achieved my desired behavior in their game or prototype?


If it is not possible, I guess I can rewrite the collision system to use 2D physics, since I have a 3d game but essentially only use the x and z axis.

Comments

  • FMProductions
    edited December 2017
    So I have found that the class TrueSync.Physics3D.RigidBody has the boolean variable "EnableSpeculativeContacts". This can be set to true in the RigidBody initialization.

    After some reading in the source code, it turns out that speculative contacts can be passed to the PhysicsWorldManager with the TrueSyncConfig. The variable "speculativeContacts3D" is available in the TrueSyncConfig prefab. The TrueSyncConfig is passed to the function PhysicsManager.New(..) which essentially creates the global PhysicsManager Singleton instance.

    Setting this to true does not seem to yield much better results (behavior may be improved, but it is still far from working correctly), my character still falls through the platform (but is slowed down during the collision with the platform).
  • I have found the cause of the behavior:
    Recently, I changed the FP implementation (FixedPoint64 data type) from having 32 fractional bits to having 20 fractional bits. I did this in order to be able to rewrite the multiplication and division function, so they are more efficient. I thought I had changed all values that depend on the fractional bits including the generation of the lookup tables for trigonometry functions.

    I switched back to the original FP implementation (Q31.32), and now it is working as intended.
    It seems I might have missed something when changing the FP implementation.. I really want to have faster division and multiplication for FP, so I will try to read through the collision detection and resolution code. If I cannot find the cause of the different behavior, I will have to switch back to the original FP implementation for my project...
  • The issue causing this behavior is probably the lost precision with my FP struct. There are many calculations with very tiny values to resolve collisions, I guess a lot of precision gets lost and those inaccuracies add together, the more calculations there are...

    I guess it would be great to have higher precision fixed point for resolving collisions but for regular calculations, an FP struct with lower decimal precision could be used...