Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rope going through wall
#6
(Yesterday, 11:29 AM)Paul1 Wrote: The player is kinematic, because Im using Photon Fusion 2's KCC, which makes player kinematic.

Kinematic objects have infinite mass so they will ignore any forces applied to them (a = F/m, if mass is infinite, acceleration is zero no matter how large the force you apply).

As a result, if you attach a rope (or any other physics object) to a kinematic object it will go wherever the kinematic object goes, as any force it applies on the kinematic object will be completely ignored. So all other constraints besides "stay attached to the kinematic object" will be ignored, this includes going inside or trough other objects in the scene if necessary.

(Yesterday, 11:29 AM)Paul1 Wrote: I want for my game to be kinematic to particles anyway, but want to have an option, if the cable detects tear, that it does not cut the rope, but if the player is holding it, it releases the rope. I havent done this yet, didnt check manual yet, do you think once I do this, I wouldnt have any those problems anymore?

Right, if you make the character release the rope once it's stretched over its rest length, you won't have this problem anymore (as the rope is no longer attached to a kinematic object)

(Yesterday, 11:29 AM)Paul1 Wrote: And if so, what should I use for detecting? Does API detect rope tearing, if the constraint is disabled? Or should I make my own tearing detection code?

You can check the constraint force of all distance constraints in the rope (this is what tearing does). If any is over a threshold value you define, detach the rope from the player. See ObiRope.cs for reference. Here's the relevant code:

Code:
            float sqrTime = substepTime * substepTime;

            var dc = GetConstraintsByType(Oni.ConstraintType.Distance) as ObiConstraints<ObiDistanceConstraintsBatch>;
            var sc = this.solver.GetConstraintsByType(Oni.ConstraintType.Distance) as ObiConstraints<ObiDistanceConstraintsBatch>;

            if (dc != null && sc != null)
            {
                for (int j = 0; j < solverBatchOffsets[(int)Oni.ConstraintType.Distance].Count; ++j)
                {
                    var batch = dc.GetBatch(j) as ObiDistanceConstraintsBatch;
                    var solverBatch = sc.batches[j] as ObiDistanceConstraintsBatch;

                    for (int i = 0; i < batch.activeConstraintCount; i++)
                    {
                        int elementIndex = j + 2 * i;

                        int offset = solverBatchOffsets[(int)Oni.ConstraintType.Distance][j];

                        // divide lagrange multiplier by squared delta time to get force in newtons:
                        float force = solverBatch.lambdas[offset + i] / sqrTime;


                        if (-force > tearResistanceMultiplier)
                        {
                            // one rope element is over the force threshold, react to it.
                        }
                    }
                }
            }
Reply


Messages In This Thread
Rope going through wall - by Paul1 - 03-08-2025, 11:59 AM
RE: Rope going through wall - by josemendez - 03-08-2025, 01:08 PM
RE: Rope going through wall - by chenji - Yesterday, 02:24 AM
RE: Rope going through wall - by Paul1 - Yesterday, 11:29 AM
RE: Rope going through wall - by chenji - Yesterday, 12:47 PM
RE: Rope going through wall - by josemendez - Yesterday, 01:02 PM