15-09-2017, 08:14 AM
(This post was last modified: 15-09-2017, 08:19 AM by josemendez.)
Hi,
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.
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.
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").
Yes, just do:
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);