Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting Questions
#4
Hi,


Quote:How can I update a rope after I change the material or the end.  If I am running a level, and I click on the initialize button, the rope will freeze.


This is the expected behavior. Initializing a rope re-creates it from scratch:

1.- Deletes all its particles and constraints from the solver, resets all per-particle properties to its default values (a warning dialog pops up telling you this when clicking the button).
2.- Generates new particles and constraints based on the spline curve.

This of course means that the rope needs to be re-added to a solver after initializing, as it is a "new rope" so to speak. Initializing a rope should generally only be done in the editor, or just once at runtime.

Changing the material or the prefab at the end should just work. No need to re-initialize the rope after changing them.


Quote:I need to update the rope in runtime and have it keep settings.

If by "update" you mean reinitializing it, it's just not possible. Reinitializing a rope clears all its properties and generates a new rope from scratch. 
Depending on what you're trying to accomplish, it should be easier to just modify the parameters you need at runtime. I see no need to reinitialize a rope at runtime, except for very specific use cases.


Quote:what is "avoid translating MeshColliders at runtime using their transform."  Do u have better description or screen shot?

I mean, do not move a MeshCollider around by doing collider.transform.position = whatever. This essentially "teleports" the collider around, which can cause particles to pass trough it or get stuck inside it since continuous collision detection will only work with rigidbodies. Either use a rigidbody, or if you cannot afford to apply physics to a MeshCollider, use primitive colliders instead.

Rigidbodies have velocity, transforms do not. Continuous collision detection needs to know the velocity of all objects involved in a collision to be able to resolve it. If these velocities are not available, the system falls back to static collision detection (which is very prone to the bullet-trough-paper problem, aka "tunneling").


Quote:Is there an easy way in code to set phase?  I would like to set all of the particles to int X on a rope.

Yes, just do:

Code:
for (int i = 0; i < rope.TotalParticles; ++i)
    rope.phases[i] = Oni.MakePhase(X,rope.selfCollisions?Oni.ParticlePhase.SelfCollide:0);
rope.PushDataToSolver(ParticleData.PHASES);
   
Reply


Messages In This Thread
Scripting Questions - by Parker - 13-09-2017, 05:11 AM
RE: Scripting Questions - by josemendez - 13-09-2017, 10:01 AM
RE: Scripting Questions - by Parker - 15-09-2017, 05:36 AM
RE: Scripting Questions - by josemendez - 15-09-2017, 08:14 AM
RE: Scripting Questions - by Parker - 15-09-2017, 01:34 PM
RE: Scripting Questions - by Parker - 16-09-2017, 07:25 PM
RE: Scripting Questions - by Parker - 16-09-2017, 10:23 PM