Search Unity

[RELEASED] Bullet Physics For Unity

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

  1. Bamfax

    Bamfax

    Joined:
    Jun 12, 2016
    Posts:
    52
    @Tinus: I can't contribute, but stumbled over some info on the web. Fyi, in case you have not read it already. It seems there was a multithreaded fork which worked for most parts of the world (softbody was mentioned not to work, if I remember correctly). It was not updated in a year, but did receive quite some activity:

    I myself would like to understand where bulletphysics is, performance-wise. In regards to what parts are running on the GPU, there is almost no info to be found about this. The only thing I found was that the broadphase would be gpu-accelerated in 2.8, but I may have misunderstood that.
    Regarding Bullet 3 and GPU experimental rigid body pipeline Erwin Coumans said in July 16 (http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?p=37889#p37889):
    • Ignore the OpenCL GPU experimental pipeline, this is not actively developed any more. AMD tried to push it but never allocated a team to work on this.
    This is not meant as ranting, I just have the feeling I might need a little more performance for my scenario, so I was reading a little bit which parts of my code or hardware should be upgraded first ;).
     
    Last edited: Sep 5, 2016
  2. Phong

    Phong

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

    I don't think you can replace a PInvoke wrapped function, but if you look at the BulletSharp wrappers, Andreas has defined a two layered wrapper. Bullet always calls the same C# function which then calls a user configured function. I would encourage you to look at the Bullet and BulletSharp sourcecode. It is easier to read than you might think. I find myself more and more looking at the Bullet source rather than googling for answers.

    It is probably a good idea to make the FixedUpdate virtual. Be careful about nesting rigid bodies. Bullet has no knowledge of a hierarchy. And updated rigid bodies in an unpredictable order. All bullet transforms are in world space. This can have strange results if two rigid bodies are nested and the leaf rigid body is updated before the parent rigidbody.
     
  3. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,359
    Definitely gonna try it! Thanks for the implementation!

    Also, could you please make a comparison video between PhysX and Bullet Physics in Unity?

    Thanks!
     
  4. Bamfax

    Bamfax

    Joined:
    Jun 12, 2016
    Posts:
    52
    They are difficult to compare. I was about to try it with the washing machine video posted above. The result was that the PhysX washing machine only pushed the PhysX cubes on the y axis, no matter what I tried (normal/kinematic, etc.), they were not getting a full impulse from the rotating machine cube. The cubes just collided nicely with each other. The Bullet implementation went perfect on first try. It was probably my fault, but I stopped it there.
    Right now I am fiddling with a multicube impulse scenario, there Bullet is far more difficult to tune, as the cubes again react more physically correct. In contrary PhysX seems to have much more "easy" behavior incl. dampening etc. I did the same scenario in PhysX before, there it was minimal tuning until it worked fine (due to this "easier" behavior, which I just recognized now on doing the Bullet version).
    Need to add that this is my unfunded experience as a newbie.
    Performance-wise PhysX should be better from what I am reading and experiencing (just talking raw power). If I am not mistaken PhysX is multithreaded (also in Unity), Bullet is singlethreaded (working user fork with threading exists, but no update in the "github please merge issue" since half a year). PhysX will eventually get GRB (GPGPU), at least it has a closed-access alpha release. Regarding Bullet OpenCL Rigidbody Erwin's last statement I found was that development is halted (see above). Reads like AMD contributed the experimental implementation, but (according to Erwin's statement) not a team which would have been needed to further this. Again, all unreflected tidbits found on the net.
    So this gave me some questions marks where Bullet is heading performance wise. Reading the web is more like a puzzle, no roadmap or milestones to be found. Wonders me a quite a bit, since an aweful lot of work seems to have went into Bullet OpenCL already, the slides mention 50 different OpenCL kernels in the Bullet implementation. Speculating a little bit, as the change from Erwin to Google was said to be for robotics, and Google was reported to have issues with their boston dynamics acquisition, I just hope that Bullet development will not be affected by it. Just my five cents. But lets get back to Bullet :). It is way cool to play around with it in Unity, Kudos to Phong (again :).
     
  5. samLo

    samLo

    Joined:
    Jul 14, 2016
    Posts:
    7
    Hey @Phong , Thanks for the awesome Bullet assets!!
    But I have a problem... When I build the apk on asus ZenPad10 or samsung s6 edge , it will cause exception.
    " DllNotFoundException: libbulletc "

    It's working fine on HTC desire 728 and samsung A7
    Our Unity version: 5.3.4f
    and the bullet engine is downloading from store.

    Do you know why cause this error?
    Thanks a lot :)
     
  6. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    To be honest I am not sure. Another has contacted me reporting that it doesn't work on the droid4x. Do you know what kind of processors the ZenPad10 and samsung s6 use?
     
  7. Bamfax

    Bamfax

    Joined:
    Jun 12, 2016
    Posts:
    52
    Finally got around to finish this little hobby project, using BulletUnity to draw a 3D Force Directed Node Graph.



    Still a draft and of course a little rough around the edges. BGhostObject riding on a BRigidbody and ScreenPointToRay work great.

    Many thanks for BulletUnity and the help, Phong.
     
    Last edited: Sep 8, 2016
    Phong likes this.
  8. Bamfax

    Bamfax

    Joined:
    Jun 12, 2016
    Posts:
    52
    Being a newbie, I still have a hard time wrapping my head around how you and Andreas implemented all of this. BulletUnity was a great help in getting accustomed to BulletPhysics, otherwise I would most definitely never have given it a go. Wrapping my head around how BulletUnity -> BulletSharp -> Bulletphysics is interconnected is still quite a challenge for me. But yes, BulletPhysics Code helps a lot. Still a lot to learn, trying to get there :). Having the source and flexibility of BulletPhysics is really a great resource, compared to PhysX.

    Yups, thanks for the reminder. I have read your readme and the warning signs on your homepage :). Being lazy, the wachine machine used an empty gameobject as rotation point for child BulletUnity kinematic washing machine walls. There it surprised me that the BulletUnity child walls did actually update nicely.

    How do you actually connect the Unity3d.Gameobject.transform back to the BulletSharp.Worldtransform, so that even a further out BulletSharp child (child not having Vector3.zero) gets a correct position/rotation? This I have not yet found out.

    And one more question: The above Graph needs a lot more performance. The BGhostObject and all AddImpulses eat quite a bit. Would it be possible to implement the simulation offline in BulletSharp, having Unity just read out the transforms once in a while in parallel?
     
  9. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Bullet Physics likes to use MotionStates to update game objects Transforms. Each RigidBody has a BMotionState associated with it when it is created. When the world is stepped, Bullet Physics calls callbacks in the motion state associated with each rigid body to assign values to Transform.position and Transform.rotation. Since Transform.position is in WorldSpace the transform is correct even if the rigid body is the child of another transform.

    If you are using the BulletSharp API, then the simulation could be completely offline. The SimpleOfflineSimulation example and RealtimeWithOfflinePrediction do this. Using BulletUnity components you will have a harder time. I think you would have to edit BPhysicsWorldHelper and BPhysicsWorld FixedUpdate to get direct control of stepping the world forward.
     
  10. samLo

    samLo

    Joined:
    Jul 14, 2016
    Posts:
    7
    samsung s6:
    Samsung Exynos 7420 64bit 1.5GHz octa-core

    ZenPad 10:
    Intel Atom x3-C3200 64 bit 1.2GHz Quad-core

    And we also found Huawei p9 plus can't work too.
    it cpu is:
    HiSilicon Kirin 955 64bit 1.8GHz Octa-core
     
  11. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Thanks. Must be nice to have access to so many devices. I will look into this later today.
     
  12. samLo

    samLo

    Joined:
    Jul 14, 2016
    Posts:
    7
    Thanks a lot. Appreciate it :)
     
  13. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    I had a look and it looks like I was only building a library for ARM devices. I have added an x86 version that should work with Android devices. I can't test it because I don't have and x86 android device. If someone could check the latest build in github and let me know if it works on Android devices with x86 processors that would be great.
     
  14. samLo

    samLo

    Joined:
    Jul 14, 2016
    Posts:
    7
    We test Asus ZenPad 10 ( intel x86 ) that's working fine.

    But Huawei p9 plus still can't work.
    We'll get the log and report.

    Thanks a lot :)
     
  15. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Looks like the Huawei p9 plus uses an ARM 64 processor. I can build a shared lib for this (distinct from the regular ARM build) but I don't know how to configure it in Unity. The Inspector in Unity for the shared lib only gives me a choice of 'ARM' and 'x86'

    [EDIT] Unity says it only supports x86 and ARM android builds. Does a Unity build APK work on the Huawei p9 if it does not include native libs?
     
    Last edited: Sep 13, 2016
  16. makky0825

    makky0825

    Joined:
    Sep 16, 2016
    Posts:
    3
    Hello @Phong , Thanks for your all works.
    However,I have a problem. Sorry to ask you such a basic question but how can I use CCD(Continuous Collision Detection)?
     
  17. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    That is something I haven't spent much time looking at yet. It is on the todo list. There is a BulletSharp example that uses it. I have not yet exposed it so that it can be configured in the BulletUnity components.
     
  18. samLo

    samLo

    Joined:
    Jul 14, 2016
    Posts:
    7
    Hi Phong, Thanks for help.
    We have some native libs in our project like Json , Google service..etc.
    We can help to test the new lib you built :)
    Did you put this new lib on the git ?
     
  19. AndresBarrera

    AndresBarrera

    Joined:
    Jan 8, 2015
    Posts:
    5
    Hello Phong,

    First of all, thanks to you and to Andres Tracks for your work.
    I have been doing some test with the plugin and have found a couple of issues trying to run it on mobile, I will list them here and hope that you can look at them to find a solution:
    1. Some errors can appear at runtime if compiling to iOS with IL2CPP. They are related to passing non-static function pointers to native code.
      • The error is: IL2CPP does not support marshaling delegates that point to instance methods to native code.
      • Some example is inside the InitTarget method of the DebugDraw class.
    2. I also have problems with libbutlletc when running in an iOS device.
      • DllNotFoundException: Unable to load DLL 'libbulletc': The specified module could not be found.
      • Changing the Unity build from Universal to Armv7 or Arm64 did the trick a couple of times I tried, but not always (weird).
    3. The same problem with libbutlletc was happening with Android, but it was fixed with your newly uploaded libulletc.so files (the ones you added to the github project last week).
    4. It seems that some functions in the Soft body classes are treated as duplicated when translated with IL2CPP to the Xcode project. For some reason, float[] and Vector3[] as params are treated as the same type regarding function signatures.
      • This code seems to be stripped from the Xcode project if no scene with soft body mechanics is added to the Unity build, so its not a big problem for us right now.
    I think that's all I have found up till now, will keep testing.
     
  20. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Thanks, I would appreciate that. Yes the new Android build is up in github. https://github.com/Phong13/BulletSharpUnity3d
     
  21. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Thanks Andres, this is a constructive list of feedback. I will try to fix the marshaling delegates that point to instance methods. I thought had fixed these but I might have missed some. Please let me know if you find any more errors.

    The DllNotFoundException is interesting. What version of Unity are you using? I havn't run into that one. Let me know if you can discover any more about it.

    Another user has mentioned the duplicated functions issue. I have some time this week so I will try to look into this.

    Thanks again for the feedback.
     
  22. AndresBarrera

    AndresBarrera

    Joined:
    Jan 8, 2015
    Posts:
    5
    I'm running Unity 5.3.6f1.
    Using just a scene with some kinematic objects moving around.

    The weird thing about the libbulletc error is that the .a file is added to the Xcode project without problems, together with all the wrap files from Plugins/Native/iOS.
    Maybe it is something related to architecture, but it seems to support both armv7 and arm64 (using: lipo -info libbulletc.a from the command line).
    Also, although it is working in Android, it prints some message in logcat like "unable to find libbulletc"... so I'm still clueless.

    I will do some more checks, maybe it is because some build configuration I have. Will have to test with a clean project with only your plugin.

    Thanks.
     
  23. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    I am having trouble reproducing these errors. I can build and deploy the Unity project in github to my ipad and it runs without problems. Unity 5.4.1, OSX 10.10.5, XCode 6.4, iOS 8.4. here is a screen shot of my inspector settings:
    Screen Shot 2016-09-25 at 11.16.15 AM.png
     
  24. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    Been playing with this for a few days, works really nicely! Awesome work.

    One question though, wondering if this works in Linux standalone builds. Has anyone tested to confirm? I'm not super familiar with Linux but am curious if this works, and if not what would be required to get it to work.

    I see in the Plugins/BulletUnity/Native folder there's a few folders for different platforms, is there anything additional needed for Linux?
     
  25. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi DMeville, currently Linux is not supported. I have not had time to install a linux distro and build the libbulletc.so library that is needed. It is on the todo list but I have not gotten round to it. It involves checking this project out of github:

    https://github.com/Phong13/BulletSharpPInvoke

    The libbulletc folder contains the projects for building bullet+wrappers shared libraries for the various platforms. A platform would need to be added for linux and a makefile created. The makefile would probably be very similar to the Android NDK makefiles.
     
    DMeville likes this.
  26. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    @Phong Ah, ok. Good to know. I've very interested in having Linux support, but I'm not familiar with Linux at all. If someone feels like building it and sharing that would be awesome. I'll poke away at it myself and see if I can figure it out, but I can't imagine I'll get very far having no idea what I'm doing :p
     
  27. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    Had someone who knows how to use Linux build the .so for me, while I wrangled with installing Linux on my machine so I could test/debug this a bit easier. After a few hours of tinkering, I can confirm this works under Linux. Not sure if I configured the .so properly in Unity, but I needed to manually copy the libbulletc.so to the player root post build(so it was beside Game_Data). After that physics worked great.

    Was testing on Ubuntu 16.04.
    Including a zip with libbulletc.so, as I can't upload the .so file directly. Unzip it, and drop it in the Plugins/Linux folder (if it does not exist, create it).
     

    Attached Files:

  28. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    This is awsome! Would it be possible to get the makefile/autoconfig/whatever was used to create the linux.so I would love to add it to the github project?
     
    Last edited: Sep 28, 2016
  29. Leuthil

    Leuthil

    Joined:
    Jul 26, 2013
    Posts:
    97
    @Phong , I've spent a bit more time trying to use Bullet to implement client side prediction. The RealtimeSimWithOfflinePrediction example scene has been extremely useful. I have been doing a few more tests to see if I can make the world replication simpler so that the code will look cleaner when implementing the client side prediction. One of my tests involved Constraints. The issue I've noticed here is that the constructors for Constraints can require more data than what seems to be exposed. For example I cannot seem to retrieve Constraint axes/pivot so it seems I can not create an exact duplicate in the offline simulation. Do you have any suggestions on how this might be possible?

    Edit: I found that I can use TypedConstraint.Userobject which (I think) will give me BTypedConstraint which I can then use to extract all the data I need similar to how the example did with BRigidBody. I think I am running out of time for the night so unfortunately I can't see the results of this test but hopefully with the right implementation it can work.

    Edit2: After doing some research I found that Bullet allows the serialization of the entire World which would be very useful to just serialize the current World and deserialize it to create the copy of it for offline simulation. However I found from the Bullet Wiki that the serialization loses some data that would be crucial such as current velocity, motion states, collision flags, etc. Source: http://bulletphysics.org/mediawiki-1.5.8/index.php/Bullet_binary_serialization

    They do mention that extending the BulletWorldImporter may allow one to also carry that data along during the serialization which would be handy but that seems like it would be quite a task.

    Edit3: Guess I stayed up longer than intended. It appears we need an implementation on BTypedConstraints similar to how BRigidbody has CreateOrConfigureRigidbody, however it's tricky since creating a copy of a constraint in an offline sim means that the rigidbodies attached to this constraint have to be the new copies in the offline sim as well. Do you know if rigidbodyA and rigidbodyB can be kept null on construction and then added later before being added to the World? My quick checks seems like it should be OK but I don't have a chance to test it yet.

    Edit4: I did create a rudimentary CreateOrConfigureConstraint on BHingeConstraint. I pulled logic out of BHingeConstraint._BuildConstraint() and moves some of it to there and then called it from _BuildConstraint similar to how CreateOrConfigureRigidbody is done. However when testing it in the offline simulation it gave different results, so I'm not sure if it's because of object ordering within the World or if I missed something else. It's a bit tough to debug unfortunately.

    Ultimately it seems like extending the DefaultSerializer may be the most effective option but it doesn't seem that easy :( at least not for someone who has no idea what they're doing :).
     
    Last edited: Sep 29, 2016
  30. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Glad to here about your progress. I had not thought of using binary serialization.

    I just reviewed the Gaffer on Games description of client-side prediction. I think that rather than doing a separate simulation, it would be better to try to implement log and rollback on the existing simulation. You will need to log the state of the rigid bodies each frame and be able to rollback the physics world to one of those logged states. This should not be too hard, although OnCollision and OnTrigger events could get fired multiple times.

    When an update comes in from the server (for a frame in the past due to network latency) the servers state is compared to the logged state. If the logged state differs from the server state then the simulation needs to be rolled back, adjusted to match the server's state and re-simulated to the present state.
     
  31. Leuthil

    Leuthil

    Joined:
    Jul 26, 2013
    Posts:
    97
    Hmm that could work but yeah I'm not sure how the physics engine will react to everything in the scene being manually shifted back to a previous state, although it shouldn't be too much in a normal PC game with high update rates. It's worth a try. I just have to figure out how to pull all the important state data out for each body in the world. It can get messy if gameplay mechanics involve adding/removing constraints or even rigidbodies for that matter. However I can do a test that simply involves moving rigidbodies and some constraints that don't change. Do you know what would happen when I get/set values on BulletUnity components to restore the state and manually step the simulation forward. Will these BulletUnity components also get updated correctly? Meaning, will their Unity transforms be updated accordingly? Or is there some type of Update method I need to call to realign the GameObjects with their Bullet rigidbody counterparts lol.

    The main reason I wanted to do an offline simulation was so that I could take the result after the client side prediction position was resimulated (if the server update showed that the client was off) and compare it to the current client side prediction position so that some form of interpolation could be done. If the same physics world is used then the interpolation would either have to be done when the server update is received or never.
     
    Last edited: Sep 30, 2016
  32. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Disclaimer: I haven't tried any of this myself so my advice may be wrong. I am going mostly by the algorithm in the Gaffer On Games article http://gafferongames.com/game-physics/networked-physics/.

    I think with Bullet there is no problem updating the state of objects (set position, rotation, velocity, angular velocity). When setting these don't use the motion state, use SetTransform on the rigid bodies. Rolling back the physics engine should work from the Bullet side. Deleted objects and changed constraints would need to be logged and these would need to be re-added when doing the rollback. I could see this getting very messy to make a robust system that handles all cases, however most games are probably limited to a subset of the possibilities.

    The bullet Unity components should be able to handle this. You could grab the Physics World from the BPhysicsWorld, rollback the states on all the bodies. Call StepSimulation until you are caught up. The biggest problem I can think of will be with OnCollision callbacks and OnTrigger callbacks. These won't be called automatically when you step the simulation forward. You will need to call OnPhysicsStep on the collisionEventHandler to get that to work. And then you could end up with multiple callbacks being called on the same frame. The callback code would need to be robust enough to handle this.

    Bullet will update the positions and rotations of your rigid bodies as you call StepSimulation. It does this through the MotionStates. You don't need to call an Update method.

    I see your point about doing an offline sim to do interpolation. I don't have enough experience with this to know if this is a good approach or not.

    I am intrigued by the idea of Serializing the world sending it over the network and recreating it. It would be too expensive to do every frame, but I would think that would be an excellent way to create the initial world so that the client and server worlds would be deterministic. I would think the tricky part would be hooking up the BulletUniity components with their corresponding bullet components when reassembling everything.
     
  33. Leuthil

    Leuthil

    Joined:
    Jul 26, 2013
    Posts:
    97
    Excellent reply! Thank you very much. I think that is all the information I need to actually create a demo (until I run into problems of course).

    In terms of the interpolation at this point I think for the sake of the demo it can be ignored. This can be done later when I have more experience working with Bullet. Although I think for more developers to adopt BulletUnity the RealtimeSimWithOfflinePrediction should be expanded to have working constraints and moving rigidbodies with velocities. The main draw of BulletPhysics to me was this concept of being able to do offline sims in Unity and to have a really solid working example would make devs very happy :).

    Yes the serialization idea is very interesting to me as well. I know that Bullet has a naming feature in their serialization system so if you manually serialize each object separately (as opposed to just Serializing the entire World from World.Serialize() or whatever it is) you can name each object specifically. Perhaps that could be of use to make that happen. However if you are only sending the Serialized world during initial game setup, then you can just create the corresponding BulletUnity components based on what objects you receive no? For each RigidBody object in the world, create a GameObject, add BRigidbody component, add the appropriate BCollisionShape, assign that RigidBody to the BRigidbody. Not simple but maybe it could work. Either way I don't know if that would really make the worlds deterministic for all clients, especially when dealing with cross platform and user inputs.
     
  34. Catobyte

    Catobyte

    Joined:
    Sep 27, 2015
    Posts:
    4
    Hi everyone,
    I've got a question/problem with Bullet physics for Unity, was wondering if you could lend advice? (although I understand it is still a WIP). I'm trying to make a vehicle in Unity using Bullet constraints (something along the lines of this). I've made a hinge constraint to allow the wheels to rotate, and then I've attached the wheels to a "bracket" which is another hinge constraint, which I want to steer. This hinge constraint is attached to the main rigidbody of the car. So I have something like this:

    RigidbodyWheel -> HingeConstraint -> RigidbodySteeringBracket -> HingeConstraint -> RigidbodyCarBody

    When I run the simulation, the constraints all sag massively, and fail to hold correct positions (the wheels collapse under the weight of the car, as a result of both HingeConstraints bending where they shouldn't). I have tried replacing all constraints above with FixedConstraints, and the same seems to happen. However, if I simply do RigidbodyWheel-> FixedConstraint -> RigidbodyCarBody, there is no sagging in the constraint.
    Is there currently an issue with constraints that are chained together like this? (or am I doing it wrong?)

    Also, great Unity package by the way. ;)
     
  35. MrPure3D

    MrPure3D

    Joined:
    Apr 1, 2014
    Posts:
    12
    Hi,

    I have the same problem, very loose joints. I do not have this problem with bullet in Maya or Cinema 4D.
    To me it looks like we have to increase accuracy and iterations in the physics solver. How do do that in Bullet Unity?

    Thanks!!
     
  36. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    With Bullet the number of iterations is set per constraint. I haven't exposed it in the inspector. Will try to do that for the next release.

    To set it for all constraints of the same type, look in the function _BuildConstraint() in files BHingedConstraint.cs, BTwistConstraint.cs etc... Add the code:

    Code (CSharp):
    1. m_constraintPtr.OverrideNumSolverIterations = 300
     
  37. MrPure3D

    MrPure3D

    Joined:
    Apr 1, 2014
    Posts:
    12
    Thanks alot, that solved it!

    Is it possible to also add Motor to the Slider constraint?
    I have problems getting the Linear Motor of the B6DOF to work. It doesnt seem to have an effect...
     
    Last edited: Oct 4, 2016
  38. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Definitely possible. Sadly, there is lots to work on and much of my time needs to go to paying work so things happen slowly. Tinus has done some work adding motors to the constraints, I will ask and see if it is possible for him to push his changes over. In the meantime, you have full source so don't hesitate to tinker yourself.
     
  39. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    I am super excited that I finally got this to work. A lot of people have been requesting the ability to add soft body parts to skinned meshes. This is a low poly soft body simulation (front), driving a skinned mesh (back). This has huge potential! I am working on a tutorial to show the setup.

     
    djsaman, Bamfax, Arganth and 2 others like this.
  40. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    djsaman and elias_t like this.
  41. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    Has anyone had any issues using this on some hardware (specifically windows, but might be happening elsewhere too)?

    Some users have reported physics not working for them. Taking a look at their logs, I'm getting a DllNotFoundException C:/Program Files. .... /Game_Data/Plugins/libbulletc.dll, but I can confirm that the libbulletc.dll IS in that folder.

    Any idea what could cause this? Is there something else that the libbulletc.dll depends on, that needs to be installed or something?

    Edit: Read through the previous posts, seems VCRUNTIME140 is required. Will try enabling the Visual C++ Redist 2015 on Steam and see if it fixes the problem...

    Edit #2: It didn't seem to work.
    Still getting "Failed to load C://....libbulletc.dll" with error 'The specified module could not be loaded" on start, and
    DLLNotFoundException: C://... libbulletc.dll" when trying to call Bullet physics related functions
     
    Last edited: Oct 24, 2016
  42. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    hi @Phong
    I've tried to put your library in my project, with some changes 'cause the world is created into my dll and works..
    I've tried to enable the debug draws and some thing are drawn but I give this error:


    have you got any ideas about this?
    thanks
     
  43. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Do you know which version of windows if being used? I had a friend try using Windows 7 a few days ago and had a problem too.
     
  44. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    The first two errors look like they could be caused by Editor code being called from the runtime client. I am not sure how that could get past the compile stage. However you mention that you are creating a .dll. Are you compiling the .dll with UNITY_EDITOR preprocessor flag? You could also look in the debug draw code and see if there is some editor stuff in there.

    Are you using threads? My guess is that the last error is caused by something calling the Unity API from a separate thread. Bullet will make Unity API calls when the simulation is stepped.
     
  45. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    thanks @Phong !
    the first errors my dll doesn't have UNITY_EDITOR preprocessor, I try to add this, for the threads yes, 'cause the world is created and runs into a different thread
     
  46. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    Yep, two reports - one on windows 8 (x64), and another on windows 10 (x64).

    Which is super weird, because one of my work machines is windows 10 and physics work fine on that player. Also tested on OSX, and a fresh Linux install, in both of these platforms have worked 100% without problems. So must be something to do with extra dependencies on windows or something, not really sure
     
  47. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Weird, I tested on an 8.1 and windows 10 machine and they both worked subject to the 2015 redistributable being installed. The projects I use to build the library are all located in github here:

    https://github.com/Phong13/BulletSharpPInvoke

    You could comb through the settings for the windows build to see if there is anything you can find. I have been considering attempting a MinGW build to see if it might eliminate the need for the redistributable but have not had time.
     
  48. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    thanks @Phong for your reply.. i'm looking into..
    i've got another question, more bullet, less unity :) I wish add in my racing simulator a vertical stop signal (for example) with a collision, so if the car crash into, the signal go away... but the problem is that is impossible place a vertical signal that stay vertical.. have you some ideas? (for example let the signal freezed until a collision happens..

    thanks again mate
     
  49. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    I presume the problem is that the signal falls over? Here are some ideas if I understand the problem correctly:

    1) Can you make the base of the signal bigger? Use a compound collider with a big flatish box on the bottom?

    2) Could you make the signal kinematic, and put a trigger around it. When the trigger is penetrated then you could switch it to dynamic.

    3) Could you fix the signal in place with a fixed constraint and give it a breaking strength?
     
  50. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    thanks!!
    the first solution is not very good, I try the second or third solution... have you some examples about the 2 and 3?