Latest Threads |
can you remove particles ...
Forum: Obi Softbody
Last Post: aardworm
09-07-2025, 07:09 AM
» Replies: 0
» Views: 105
|
ObiRope Mesh Renderer
Forum: Obi Rope
Last Post: quent_1982
08-07-2025, 11:27 AM
» Replies: 4
» Views: 383
|
How to dynamically change...
Forum: Obi Rope
Last Post: quent_1982
08-07-2025, 06:34 AM
» Replies: 6
» Views: 533
|
Pipeline that bends
Forum: Obi Softbody
Last Post: josemendez
04-07-2025, 09:52 AM
» Replies: 13
» Views: 1,258
|
How to implement/sync Obi...
Forum: Obi Rope
Last Post: quent_1982
01-07-2025, 01:48 PM
» Replies: 2
» Views: 353
|
Collisions don't work con...
Forum: Obi Rope
Last Post: chenji
27-06-2025, 03:05 AM
» Replies: 3
» Views: 431
|
Force Zone apply differen...
Forum: Obi Rope
Last Post: chenji
26-06-2025, 11:41 AM
» Replies: 11
» Views: 1,209
|
Can I blend in and out of...
Forum: Obi Cloth
Last Post: josemendez
24-06-2025, 04:42 PM
» Replies: 3
» Views: 419
|
Using a rigidbody/collide...
Forum: Obi Cloth
Last Post: josemendez
24-06-2025, 09:29 AM
» Replies: 1
» Views: 246
|
Solver is too performance...
Forum: Obi Rope
Last Post: quent_1982
20-06-2025, 08:09 AM
» Replies: 40
» Views: 5,519
|
|
|
Ropes have no collision |
Posted by: Schmaniel - 08-09-2021, 10:18 PM - Forum: Obi Rope
- Replies (2)
|
 |
Good day,
I am having troubles spawning ropes from the code.
I wrote my code very similar to GrapplingHook.cs (a sample scene).
I now have the problem that the so-spawned ropes have no collision. Here is the code from that.
Any ideas where the problem could be?
Code: public void SpawnWire(Vector3 end1, Vector3 localHit)
{
// Create the rope
GameObject emptyGameObjectForOneRope = new GameObject();
emptyGameObjectForOneRope.transform.parent = this.transform;
rope = emptyGameObjectForOneRope.AddComponent<ObiRope>();
ropeRenderer = emptyGameObjectForOneRope.AddComponent<ObiRopeExtrudedRenderer>();
//ropeRenderer.section = section;
ropeRenderer.uvScale = new Vector2(1, 5);
ropeRenderer.normalizeV = true;
ropeRenderer.uvAnchor = 0;
ropeRenderer.thicknessScale = 0.5f;
rope.GetComponent<MeshRenderer>().material = material;
// Setup a blueprint for the rope:
blueprint = ScriptableObject.CreateInstance<ObiRopeBlueprint>();
blueprint.resolution = 0.5f;
blueprint.thickness = 0.5f;
blueprint.pooledParticles = 100;
// Tweak rope parameters:
rope.selfCollisions = true;
rope.surfaceCollisions = true;
rope.collisionMaterial = obiCollisionMaterial;
// Add a cursor to be able to change rope length:
cursor = emptyGameObjectForOneRope.AddComponent<ObiRopeCursor>();
cursor.cursorMu = 0;
cursor.direction = true;
////////////////////////////////////////////////////
this.end1 = end1;
this.localHit = localHit;
StartCoroutine("CoRoutineXD");
// Procedurally generate the rope path (a simple straight line):
}
public IEnumerator CoRoutineXD()
{
yield return 0;
// Procedurally generate the rope path (not quite a simple straight line, I could change it back though):
blueprint.path.Clear();
blueprint.path.AddControlPoint(end1, Vector3.back, Vector3.forward, Vector3.up, 0.1f, 0.1f, 1, 1, Color.white, "Hook start");
blueprint.path.AddControlPoint(localHit, Vector3.forward, Vector3.back, Vector3.up, 0.1f, 0.1f, 1, 1, Color.white, "Hook end");
blueprint.path.FlushEvents();
// Generate the particle representation of the rope (wait until it has finished):
yield return blueprint.Generate();
// Set the blueprint (this adds particles/constraints to the solver and starts simulating them).
rope.ropeBlueprint = blueprint;
rope.GetComponent<MeshRenderer>().enabled = true;
//
// Pin both ends of the rope (this enables two-way interaction between character and rope):
var pinConstraints = rope.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>;
pinConstraints.Clear();
var batch = new ObiPinConstraintsBatch();
batch.AddConstraint(rope.solverIndices[0], gameObject.GetComponent<ObiCollider>(), localHit, Quaternion.identity, 0, 0, float.PositiveInfinity);
batch.AddConstraint(rope.solverIndices[blueprint.activeParticleCount - 1], gameObject.GetComponent<ObiCollider>(),
end1, Quaternion.identity, 0, 0, float.PositiveInfinity);
batch.activeConstraintCount = 2;
pinConstraints.AddBatch(batch);
rope.SetConstraintsDirty(Oni.ConstraintType.Pin);
cursor.ChangeLength(wireLength);
|
|
|
|