Search Unity

[RELEASED] Bullet Physics For Unity

Discussion in 'Assets and Asset Store' started by Phong, May 31, 2016.

  1. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    For the third solution you could look in the constraints example scene. I think there is a fixed constraint in there somewhere. You probably need to experiment to find the right breaking strength.

    For the 2nd solution you could look in the Triggers example. Note that when switching from kinematic to dynamic you need to update the mass and interitia to get the change to take.
     
  2. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    If anyone is trying the latest AssetStore version there are errors in the example scenes. The BSphereShape.cs.meta file was corrupt which caused missing script errors on the game objects. I have submitted a fix but it will take a few days to go live. The fix is live in github.

    It is easy to fix. Just delete the BSphereShape.cs.meta and Unity will generate a new one. Then drag the BSphereShape to any of the objects in your scene that have missing script errors.
     
  3. jknight-nc

    jknight-nc

    Joined:
    Jun 10, 2014
    Posts:
    52
    I'm comparing the performance of stacks of cube rigid bodies between bullet and unity's default physics system. I'm finding the unity default system more performant and more stable. Is this expected?

    I'm interested in bullet physics both from a performance perspective and from a networking perspective.
     
  4. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    I have not spent a lot of time yet profiling and optimizing. I expect that PhysX will be difficult to beat performance-wise since I am forced to work through PInvoke wrappers whereas PhysX has a deeper level of integration with Unity. Can you report on how much of a performance difference you are finding?

    I am surprised about the stacking. Can you report on what you are comparing? There are some Bullet stacking examples in the benchmark scene that are fairly impressive.
     
  5. jknight-nc

    jknight-nc

    Joined:
    Jun 10, 2014
    Posts:
    52
    I'm testing tight stacks like this:



    ->




    With "Adaptive Force" Enabled on Unity, the same stack just about stands up perfectly. Also, my BPhysics instance can run fewer of these stacks compared with Unity.


    Stacks like this is the basis of the destruction in my voxel based game, and I'm seriously interested in upping the performance of the Unity Physics Solution. Including possibly writing a GPU powered solution.
     
  6. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    I'm trying to add a constraint, but seems that the constraint from a point doesn't work..
    so the fixed doesn't work with a point? is right?
     
  7. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Just had a look and it looks like that is correct. Is the sign sitting on something? Can you constrain it to that object? I just did a little test and constraining to another kinematic object works well.
     
  8. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    thanks @Phong ! my signal is over a btCollisionObject
     
  9. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    It looks like the API for BulletSharp only has a constructor that takes two RigidBodies. There may be another constructor in the Bullet Source that is not exposed, I haven't checked. Can you switch the btCollisionObject to a static btRigidBody?
     
  10. samLo

    samLo

    Joined:
    Jul 14, 2016
    Posts:
    7
    Hi Phong,

    Thanks for help.
    We have tested HUAWEI p9 but it doesn't work.
    The error log is "unable to find libbulletc , DllNotFoundException: libbulletc"

    Our test Unity version is 5.4.2f2 :)
     
  11. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hmm, unity only lets me include libraries for armV7 and x86. My guess is that the HUAWEI p9 uses something else (armV8 maybe).
     
  12. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    hello @Phong !
    I've find a partial solution, but I need your help 'cause I've got a big issue :)
    unfortunately my dll with the bullet physics has the y and z inverted... with the rigidbodies it works, I've hacked some files and I invert these 2 values and the physics works correctly with the 3d in unity...
    now I've tried to do the constraint (6dof with the limit to 0, 'cause my version of bullet is old and doesn't contain the fixed constraint (I've looked and the fixed is just a 6dof with the limits to 0.. so maybe no problems...)
    I've created a static cube and placed above the signal

    and looks like this.. but when I run.. the signal goes here:

    I'm almost sure that there's some error by yz flip, but where? i've tried to flip the constraint point (ot: what means the constraint point, the constraint axis x and constraint axis y?

    thanks in advance!
     
  13. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    This is confusing. I found it easiest to look at the bullet source to see what is going on. The constraint point is local to the object the constraint is being attached to. I can't remember what the reference frame the constraint axis x and y are in. Another confusing thing is that Bullet Transforms are row major which was screwing me up for a while. Here is the source code BulletUnity uses to build the frames which seems to work:

    Code (CSharp):
    1.        
    2. public bool CreateFrame(UnityEngine.Vector3 forward, UnityEngine.Vector3 up, UnityEngine.Vector3 constraintPoint, ref BulletSharp.Math.Matrix m, ref string errorMsg)
    3.         {
    4.             BulletSharp.Math.Vector4 x;
    5.             BulletSharp.Math.Vector4 y;
    6.             BulletSharp.Math.Vector4 z;
    7.             if (forward == Vector3.zero)
    8.             {
    9.                 errorMsg = "forward vector must not be zero";
    10.                 return false;
    11.             }
    12.             forward.Normalize();
    13.             if (up == Vector3.zero)
    14.             {
    15.                 errorMsg = "up vector must not be zero";
    16.                 return false;
    17.             }
    18.             Vector3 right = Vector3.Cross(forward, up);
    19.             if (right == Vector3.zero)
    20.             {
    21.                 errorMsg = "forward and up vector must not be colinear";
    22.                 return false;
    23.             }
    24.             up = Vector3.Cross(right, forward);
    25.             right.Normalize();
    26.             up.Normalize();
    27.             x.X = forward.x; x.Y = forward.y; x.Z = forward.z; x.W = 0f;
    28.             y.X = up.x; y.Y = up.y; y.Z = up.z; y.W = 0f;
    29.             z.X = right.x; z.Y = right.y; z.Z = right.z; z.W = 0f;
    30.             m.Row1 = x;
    31.             m.Row2 = y;
    32.             m.Row3 = z;
    33.             m.Origin = constraintPoint.ToBullet();
    34.             return true;
    35.         }
    36.  
    37.  
    38.         // Object A has the constraint compontent and is constrainted to object B
    39.         // The constraint frame is defined relative to A by three vectors.
    40.         // This method calculates the frames A and B that need to be passed to bullet
    41.         public bool CreateFramesA_B(UnityEngine.Vector3 forwardInA, UnityEngine.Vector3 upInA, UnityEngine.Vector3 constraintPivotInA, out BM.Matrix frameInA, out BM.Matrix frameInB, ref string errorMsg)
    42.         {
    43.             frameInA = BM.Matrix.Identity;
    44.             if (!CreateFrame(forwardInA, upInA, constraintPivotInA, ref frameInA, ref errorMsg))
    45.             {
    46.                 frameInB = BM.Matrix.Identity;
    47.                 return false;
    48.             }
    49.             BM.Vector4 x = frameInA.Row1;
    50.             BM.Vector4 y = frameInA.Row2;
    51.             BM.Vector4 z = frameInA.Row3;
    52.             Vector3 xx = new Vector3(x.X, x.Y, x.Z);
    53.             Vector3 yy = new Vector3(y.X, y.Y, y.Z);
    54.             Vector3 zz = new Vector3(z.X, z.Y, z.Z);
    55.             Quaternion q = transform.localRotation * Quaternion.Inverse(m_otherRigidBody.transform.localRotation);
    56.             xx = q * xx;
    57.             yy = q * yy;
    58.             zz = q * zz;
    59.             frameInB = BM.Matrix.Identity;
    60.             frameInB.Row1 = new BM.Vector4(xx.ToBullet(), 0f);
    61.             frameInB.Row2 = new BM.Vector4(yy.ToBullet(), 0f);
    62.             frameInB.Row3 = new BM.Vector4(zz.ToBullet(), 0f);
    63.             frameInB.Origin = m_otherRigidBody.transform.InverseTransformPoint(transform.TransformPoint(constraintPivotInA)).ToBullet();
    64.             return true;
    65.         }
     
  14. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    thanks mate!!
    but is not completely clear: i have a static cube and a signal: the constraint is attached to the signal... the point where must be placed?
     
  15. Boemak

    Boemak

    Joined:
    May 29, 2013
    Posts:
    48
    First off, thanks for your wonderful work with Bullet. It is really nicely done.

    I do have a question regarding softbodies. I want to build a crane that can hoist something. I have a working prototype using anchors and the included SoftBody Rope script.

    The problem is that if I attach a hook on the far end of the rope it won't rotate along with the last piece of the rope. The hook always keeps the same rotation.

    How can I build this? Mind you I am completely new to this. :)

    Also is it possible to draw a Cylinder and use that as a rope?
     
  16. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    When you read the node positions for the rope, are you reading the normals as well? I think this will give you the "twist" of the rope at each node. You should be able to build a rotation from that and apply it to the hook.

    If you want a cylinder you can create a skinned mesh with a bunch of bones along its axis. You could map the bones to the soft body nodes directly, or use a spline (catmull rom is good) to interpolate the soft body nodes so that the number of bones does not need to match the number of soft body nodes exactly. I would recommend the spline approach. I am using that for EVA Infinity:

     
  17. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    The point is in the coordinate system of the signal. For a fixed constraint, I don't think the point matters. You could place it at 0,0,0 which should be the origin of the signal. For "FrameInB" however you will need to calculate where the origin of the signal is in the reference frame of the object you are constraining to.
     
  18. Boemak

    Boemak

    Joined:
    May 29, 2013
    Posts:
    48
    Thanks for your answer, I just hooked it up as an anchor hoping that it would automagically behave the way I expected it to.

    So I have to read the last piece of the rope, get the rotation and apply it to the hook. Cool, at least I know what to do now and that it is something that I need to do manually.

    I've made the Nodes property public in your SoftBody script otherwise there was no getting to the data that I could see. It looks like there is no rotation stored for the vertexes. Aren't they just positioned in space but have no rotation because they are just points in space?

    I've checked both verts and norms. norms is always a vector3 of 0f,0f,f0.

    Or do I need the info from linerenderer?
     
    Last edited: Nov 3, 2016
  19. Boemak

    Boemak

    Joined:
    May 29, 2013
    Posts:
    48
    Ok I got it the way I want it.

    I've made the verts array in your script public so I can access them.
    So I changed it from Protected to public.

    I take the last and secondtolast vertex from this array and in fixed update I calculate a vector from these two positions and apply a transform.rotation with this vector to my object.

    Code (CSharp):
    1.    
    2. void FixedUpdate()
    3.     {
    4.        
    5.         var heading = Rope.verts[Rope.verts.Length -2] - Rope.verts[Rope.verts.Length -1];
    6.         transform.rotation = Quaternion.FromToRotation(Vector3.up, heading);
    7.        
    8.  
    9.     }
    10.  
    It is probably very ghetto but it works.
     
  20. Boemak

    Boemak

    Joined:
    May 29, 2013
    Posts:
    48
    Ok, another question :)

    I now need to scale the rope to simulate the actual hoisting. I've checked the Bullet forums and the Erwin answered a similar question that you can use the RestLength parameter to scale the softbody.

    So If I understand correctly from reading the forums and your code is that a link is a kind of a bone that is used to deform the mesh. The restlength is the space between nodes. Problably uses something like: Length of rope divided by number of nodes = Space between nodes. So if I were to subtract a value from RestLength than the whole rope should become shorter right?

    The problem is that it does not work. I made the SoftBody a public property which gives me access to the Links collection and the RestLength property. In a FixedUpdate Routine I change these values.

    Am I missing something?
     
  21. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    That's an interesting idea, I hadn't thought of that. I am not sure why it's not working. Don't be afraid to look at the Bullet Sourcecode. The build I used is located here:

    https://github.com/Phong13/BulletSharpPInvoke

    I have learned that five minutes of looking at the source is usually more productive than hours in the forums. It is even possible to debug into the bullet source from a call in Unity.
     
  22. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    I've looked and the trigger is due by the ghost object, how can I do to add this to a rigid body? thanks :)
     
  23. chenjingsuzhou

    chenjingsuzhou

    Joined:
    Nov 24, 2014
    Posts:
    7
    Is this physics completely deterministic.
    I want a deterministic physics for Lockstep.
    Or any method to change it to deterministic?
    Thanks!
     
  24. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    The same simulation on the same machine is deterministic. The same build on the same platform is deterministic. It is not guaranteed to be deterministic running builds of the same version on different architectures/platforms. One inconvenient thing is that the rigid bodies, constraints etc... need to be added to the simulation in the same order or the collisions can be resolved in a different order.
     
  25. samLo

    samLo

    Joined:
    Jul 14, 2016
    Posts:
    7
    Hi Phong,
    we test collision callback about bvh triangle mesh shape , but it's result is wrong.
    I think our test shape is non-convex shape , so the collision callback is not we expected.
    It will trigger on convex point.

    Is it any point that I forget to setting?
    Thanks!
     
  26. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    I presume your object is static? For dynamic objects you should do a ConvexDecomposition.

    Ignoring the collision callback for a moment, does the collider collide correctly with other colliders? If it does then I think the problem is with the way the collision callbacks work. In Bullet it looks like the Collision callbacks start before there is actual contact (if the bounding box + margins penetrate each other). Check the to see if there are any contact points. My collision callback code is pretty basic. You could dig into it to make it smarter. Let me know if this is the problem.
     
  27. Medusa-Zenovka

    Medusa-Zenovka

    Joined:
    Oct 1, 2014
    Posts:
    29
    How does raycasting work based on a real code? I tried to replicate the methode used on Bamfax's approach and I tried to puzzle the pieces of information in this thread together to get a woriking raycasting system that I could use outside of Unitys main loop, but my raycast doesnt work.
     
  28. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Here is a simple script that does a raycast.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using BulletSharp;
    5. using BulletUnity;
    6.  
    7. public class TestRaycast : MonoBehaviour {
    8.  
    9.     public void Update()
    10.     {
    11.         if (Time.frameCount == 10)
    12.         {
    13.             BulletSharp.Math.Vector3 fromP = transform.position.ToBullet();
    14.             BulletSharp.Math.Vector3 toP = (transform.position + Vector3.down * 10f).ToBullet();
    15.             ClosestRayResultCallback callback = new ClosestRayResultCallback(ref fromP, ref toP);
    16.             BPhysicsWorld world = BPhysicsWorld.Get();
    17.             world.world.RayTest(fromP, toP, callback);
    18.             if (callback.HasHit)
    19.             {
    20.                 Debug.LogFormat("Hit p={0} n={1} obj{2}",callback.HitPointWorld,callback.HitNormalWorld,callback.CollisionObject.UserObject);
    21.             }
    22.         }
    23.     }
    24. }
     
    Medusa-Zenovka likes this.
  29. Medusa-Zenovka

    Medusa-Zenovka

    Joined:
    Oct 1, 2014
    Posts:
    29

    Thanks alot! I now know what my error was when I created the ray and additionally it was caused by the heavy modifications I did in order to make the engine run outside of Unitys main thread with my custom transform system.
     
  30. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, I'm considering put soft bodies into my game. IIRC, Bullet doesn't interact with PhysX components, right?

    I saw some physics engine allow their object to interact with PhysX by proxy, say attach a component like "MyPhysRigidbodyProxy" to PhysX rigidbody, then both engines can work correctly eventhough they don't know eachother. Does Bullet support this way?

    Appreciate your help :)
     
  31. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    You are correct that there is no interaction between PhysX and Bullet.

    I have not heard, of PhysX proxy objects. Do you have any links to information about it? It sounds useful. I wonder how the two physics engines decide who resolves the collisions?

    One thing you can do currently is put PhysX and Bullet components on the same object. Set one rigidbody to kinematic and the other rigidbody to dynamic. Then the objects can see each other. You can even write a script to get the contact points from collisions in the kinematic world and apply these as forces in the dynamic world which allows some limited interaction.
     
  32. Medusa-Zenovka

    Medusa-Zenovka

    Joined:
    Oct 1, 2014
    Posts:
    29
    Is there a way to make your own adjustments to the physics library such as changing btVector3 into double if thats not done already?
     
  33. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Absolutely. Projects I use to build the native plugins are in github here: https://github.com/Phong13/BulletSharpPInvoke
    You can build and modify as you like. Every byte open source.
     
  34. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    I guess they mirror PhysX rigidbodies in their engine, then handle collisions separately. However, these're totally out of my range so you could have a look.

    This is that asset said they have proxies. http://heartbroken.bitbucket.org/trussphysics/document/scripting-api/txrigidbody/
    Its asset store link: https://www.assetstore.unity3d.com/en/#!/content/41801
     
  35. pht7ec

    pht7ec

    Joined:
    Nov 24, 2016
    Posts:
    2
    Hello Phong,

    I downloaded your project from github (\BulletSharpUnity3d-master) (my Asset Store does not work) and loaded your ExampleMenu.unity. When hitting play button, everything seems normal, but when I try to open any example "ExampleRunner" following error appears :

    Failed to load 'Assets/Plugins/BulletUnity/Native/x64/libbulletc.dll' with error 'The specified module could not be found.

    I have read previous posts to find a solution and tried:
    I have Windows 7 (x64) and Unity 5.4.0f3 .
    Do you have any ideas what it could be?
     
  36. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi pht7ec,

    Another user has mentioned problems with Windows 7. I don't have Windows 7 installed on any of my PCs. I think there must be a problem with the way I am compiling it. I have been meaning to install win 7 to test but don't have a spare PC so it is a bit tricky . The project for building libbulletc.dll is here https://github.com/Phong13/BulletSharpPInvoke. Feel free to download and try to build it to see if you can get it to work. If you do discover the problem please let me know.
    I will try to find time to look into this but am very busy so no promises.

    [EDIT] I bought a couple of used hard drives for some ancient laptops in my basement. I will try to make these into Windows 7 and 8 test machines.
     
    Last edited: Nov 25, 2016
  37. Medusa-Zenovka

    Medusa-Zenovka

    Joined:
    Oct 1, 2014
    Posts:
    29
    Honestly the DLLs suck. Is there a complete C# source that can be implemented into Unity?
     
    Last edited: Nov 27, 2016
  38. Shiratori

    Shiratori

    Joined:
    Aug 27, 2014
    Posts:
    21
    Hi. First of all, thanks for all the effort you put into making this port of bullet to Unity!

    I have some questions on the proper way of spawning and destroying GameObjects with bullet components.

    I have set up a simple player prefab with an attached bCharacterController and a bCapsuleshape. Spawning the prefab using Instantiate is working fine, however I run into issues with disabling or destroying the GameObject.

    If I disable the GameObject, SetAabbRef in BroadphaseInterface gets a null reference to the BroadphaseProxy passed in. If I Destroy the GameObject, Unity crashes.

    I must be using the Bullet components incorrectly, but I haven't found any example of dynamically spawning objects with the bullet components from the examples.

    Best regards, Shiratori.
     
  39. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Shiratori, this sounds like a bug. I suspect the issue is with the BCharacterController. I had not tried dynamically creating and destroying that. I am sure the capsule shape works fine. I think the rathergood playground instantiates a lot of objects at runtime. Enabling and Disabling should add and remove the bullet physics object.
     
  40. Shiratori

    Shiratori

    Joined:
    Aug 27, 2014
    Posts:
    21
    Hi, thanks for the reply. I've also experimented with a rigidbody based character controller which moves by controlling the velocity which works quite nicely. One issue I'm having though is that the character becomes unresponsive if not giving the character any input after a variable length of time. No input on the rigidbody gives any response, including manipulating the velocity directly or adding any impulse or force.
    If the character gets pushed by another rigidbody it seems to come back to life. I was thinking it was something to do with bullet sleeping an inactive body, but I'm not sure how to either disabling the sleeping for certain bodies such as players that might be inactive for some time but should always be ready to move or activating the body manually.

    Any thoughts on this behavior?

    Sorry for the amounts of questions, but I'm new to the bullet framework and I'm evaluating if moving to the bullet physics is gonna work out for me. I'm looking for a replacement to the built in Unity physics to be able to manually step the physics simulation in order to implement client side prediction in a server authoritative multiplayer setting and your port made me really happy since I've been looking for someone to port it to unity for some time :).

    Best regards.

    EDIT:

    Sorry, I jumped the gun. I had some time to research and with a linearSleepingThreshold of 0 the body never goes to sleep. I'm gonna leave my post in case anyone else has the same issue. You don't need to respond to this post.

    Best regards.
     
    Last edited: Nov 29, 2016
  41. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    HI Shiratori,

    No problem on the question. I am away from my computer at the moment, but there should be a setActivationState(DISABLE_DEACTIVATION) method on the BulletSharp RigidBody class. Something like this should work (UNTESTED).

    Code (CSharp):
    1. BRigidBody myRigidBody;
    2. BulletSharp.RigidBody rb = myRigidBody.GetCollisionObject();
    3. rb.SetActivationState(ActivationState.DISABLE_DEACTIVATION);
    4.  
    A good place to check for answers is the bullet physics forums http://www.bulletphysics.org/Bullet/phpBB3/. The BulletSharp API is almost 1-1 so most of the answers posted there should work.
     
    Shiratori likes this.
  42. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi pht7ec,

    I finally got around to installing Windows 7 64 on an old laptop (what a pain that was). I downloaded Unity (5.4.3) and installed VS 2015 and everything worked. Unfortunately, I am a little stumped since I have been having problems reproducing this problem. If you have any further insights please let me know.
     
  43. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    the error is when you doesn't have vcredist installed... are you sure to have installed the proper version?
    I've got the same issue, and after installing vcredist everything was fine (in doubt installed vcredist86 and vcredist64)
     
  44. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Shiratori, I fixed the problem enabling/disabling/destroying the character controller and pushed the change to github.
     
  45. pht7ec

    pht7ec

    Joined:
    Nov 24, 2016
    Posts:
    2
    It really was vcredist which causes the error. I just re-installed Visual C++ Redistributable 2015 and everything works fine now. Thanks a lot!

    EDIT:
    I also had Visual C++ Redistributable 2013 installed on my PC, but you specifically need a proper version of 2015.
     
  46. Fluffy-Tails

    Fluffy-Tails

    Joined:
    Jun 28, 2009
    Posts:
    120
    Hi Phong, I just discovered this free asset, and I was primarily influenced by the dancing anime girl on the website :3

    I've been searching high and low to find an asset that fits a unique need my project requires.

    I'm not a programmer but an artist, are there plans to support Adventure Creator and PlayMaker?
    I rely on those two, otherwise I couldn't make a game.

    PlayMaker is basically my life-line for programming, because I just don't enjoy it.

    My game, Naughty Tails on Patreon: NSFW WARNING!
    https://www.patreon.com/NaughtyTails

    It's an adult furry or kemono game and it features explicit sexual content.

    I was referred to Bullet Physics for things like breast and nipple grabbing and stimulation, male and female genitalia penetration among other things.
    One of the crucial things I need in my game is vaginal and mouth physics for vaginal and oral sex.

    What I want to do is allow the player to grab hot-spots in Adventure Creator to move parts of the vagina open in a loosely controlled manner.
    An example is to spread the vaginal lips to allow various sexual activity while allowing some areas for a fall-off to maintain that stretchy yet jiggle like quality.

    I've spent countless months researching vaginal anatomy and analyzed videos extensively to better understand how this all works.

    It seems most physics concentrate on a single mass for cloth, hair and flags... I have a different purpose.

    When a character with a penis is going to push it into a vagina, I need physics that basically conform realistically to the shape of the penis but maintain the overall volume and let it snap back to its original shape like a rubber-band.

    For mouth physics, I need squash and stretch to conform to the radius of the penis.

    Additionally, I intend to create morph targets of some sort to allow for species generation probably with MegaFiers or some other solution, would the physics apply to instanced models of a base-mesh?

    As a test, I intend to create a scene featuring a character using a dildo to test penetration.

    Is any of this possible with Bullet Physics?
     
  47. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    You could give it a try. I have created a tutorial for combining skinned meshes with soft bodies. http://digitalopus.ca/site/bullet-physics-tutorial-attaching-softbodies-to-skinned-meshes/. With a small enough timestep and high enough resolution almost anything is possible. The question is: can you get good enough results in realtime. If you want the softbodies to deform in response to collisions you will need higher resolution than what I have used in the tutorial. I would suggest reading up on how bullet physics collisions work for soft bodies.

    To be honest though, if you are not a programmer you might find this tough going. Physics programming is usually fairly complex.
     
  48. Frank-Yeh

    Frank-Yeh

    Joined:
    Jan 23, 2013
    Posts:
    3
    Hi all,
    I'm using this plugin to make my own project, but when I tested it on HAUWEI's device, it crashed. The log attached below:
    #0. Crashed: UnityMain: 0 0 0x0000000000000000 at BulletSharp.TriangleMesh..ctor(BulletSharp.TriangleMesh.) at BulletUnity.BBvhTriangleMeshShape.GetCollisionShape(BulletUnity.BBvhTriangleMeshShape) at BulletUnity.BRigidBody.LGGLOHNHNDG(BulletUnity.BRigidBody) at BulletUnity.BPhysicsWorld.AddRigidBody(BulletUnity.BPhysicsWorld) at BulletUnity.BRigidBody.KKNBGAJKGFJ(BulletUnity.BRigidBody) at BulletUnity.BCollisionObject.Start(BulletUnity.BCollisionObject)

    It looks like the DLL file could not be loaded so crashed during construction mesh colliders.
    I tried the same build on other devices, such as Samsung, Sony, ASUS, HTC, all of the others are fine.
    Anyone knows this situation and solved it?

    Thank you.
     
  49. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Do you know the architecture of that device? Officially, Unity only supports ARM and x86 based Android devices. The plugin loader will only load plugins for these architectures. Its a bit frustrating because Unity seems to run on other chipsets but I can't load plugins for them.
     
  50. Frank-Yeh

    Frank-Yeh

    Joined:
    Jan 23, 2013
    Posts:
    3
    Hi, thanks for quick reply, the device is HAUWEI P9 Plus, the CPU is HiSilicon Kirin 955, it's a ARMv8 CPU.