07-06-2024, 03:31 PM
(This post was last modified: 07-06-2024, 03:34 PM by josemendez.)
(07-06-2024, 12:45 PM)kripa1415 Wrote: I tried your suggestion. setting stretching scale to 1 and stretchCompliance 0 causing unity to crash.
Those are the default values, so there must be something else causing the crash. There's a few things that don't quite add up:
- The rope is 0.45 meters thick (blueprint.thickness = 0.45f). That's a really thick rope, unless ropes in your game are hundreds of meters long I don't think that's intentional? Even if that's the case, a rope that's hundreds of meters long will behave as if it was moving in slow motion under normal earth gravity. It is advisable to stick to real-world units when dealing with physics, which means a board for a game of this type shouldn't be more than a couple meters in size.
- The tangent vectors are really strange. All control points have tangents that point from the first point in the rope to the current point (direction = (point2 - point) * 0.25f), which will make the rope kink along its path. The "point" variable is set for the first point, but never changed afterwards. This will only work somewhat ok if points.Length == 2, I don't know how many points are in it but seems like there's more than two? (since you check for the first and last points to change their mass)
- You're pinning the ends of the rope to the center of colliders (offsetA and offsetB set to zero) that may be colliding with the rope, since the code doesn't modify the collision filters of either the rope or the colliders. This will result in unphysical behavior as described in the manual: the collider wants the rope to be outside, but the attachment wants the rope to be inside, but it's impossible for an object to be simultaneously inside and outside something.
Other than these, the code looks fine. If the problems persist I think the only practical way forward would be for me to take a look at your project and see what's causing them, if possible send it to support(at)virtualmethodstudio.com so that I can diagnose these issues.
kind regards,