Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  Errors when ending playmode
#27
(25-02-2020, 04:09 PM)TheMunk Wrote: Thanks - got me a bit further although not the entire way.
I'm doing this on Fixed Update;

Code:
highestParticleMagnitude = 0;
       highestVelocity = new Vector4(0, 0, 0, 0);

       // Iterate over all particles in an actor:
       for (int i = 0; i < rope.solverIndices.Length; ++i)
       {

           // retrieve the particle index in the solver:
           int solverIndex = rope.solverIndices[i];

           // look up the particle velocity:
           if ((rope.solver.velocities[solverIndex] * Time.fixedDeltaTime).magnitude > highestVelocity.magnitude)
           {
               highestVelocity = (rope.solver.velocities[solverIndex] * Time.fixedDeltaTime);
               highestParticleMagnitude = rope.solver.velocities[solverIndex].magnitude;
           }
               
       }

But it looks like the velocities stops updating after some time even though the rope is still moving (see here):

As you can see the VelocityVisualizer from your documentation seems to work fine though, so why isn't mine updating?
Changing sleep threshold in the solver doesn't help.

EDIT:
It seems to work right until I shorten the rope, then it breaks... Without errors.

Hi,

It's hard to tell, but in your video the highest velocity seems to stop updating right when the rope particles stop moving. Isn't this the expected result?

Also, multiplying velocities by the delta time converts them to position deltas. I'm not sure if this is intended, but most likely not. Velocities are expressed in  meters/second, so you don't need to multiply them by anything (unless you want to use a threshold expressed in meters, but then it wouldn't be independent of the timestep)

Edit: I just realized that you might have copied the "actor.solver.velocities[solverIndex] * Time.fixedDeltaTime" from the documentation. I did this because the sample visualizer draws a line between two positions (the particle position, and the position where it will move to the next frame, due to its velocity) so I need to integrate velocity over time to get a position, hence the * Time.fixedDeltaTime. Remember from basic physics that velocity = distance/time, so distance = velocity * time. You don't want to work with distances but with velocities.
Reply


Messages In This Thread
Errors when ending playmode - by TheMunk - 27-01-2020, 01:35 PM
RE: Errors when ending playmode - by TheMunk - 28-01-2020, 11:10 AM
RE: Errors when ending playmode - by TheMunk - 28-01-2020, 12:14 PM
RE: Errors when ending playmode - by josemendez - 28-01-2020, 12:38 PM
RE: Errors when ending playmode - by TheMunk - 28-01-2020, 12:59 PM
RE: Errors when ending playmode - by josemendez - 28-01-2020, 04:24 PM
RE: Errors when ending playmode - by TheMunk - 28-01-2020, 04:45 PM
RE: Errors when ending playmode - by josemendez - 28-01-2020, 05:00 PM
RE: Errors when ending playmode - by TheMunk - 29-01-2020, 09:56 AM
RE: Errors when ending playmode - by josemendez - 29-01-2020, 10:05 AM
RE: Errors when ending playmode - by TheMunk - 13-02-2020, 10:30 AM
RE: Errors when ending playmode - by josemendez - 13-02-2020, 01:14 PM
RE: Errors when ending playmode - by TheMunk - 13-02-2020, 02:04 PM
RE: Errors when ending playmode - by TheMunk - 13-02-2020, 03:39 PM
RE: Errors when ending playmode - by TheMunk - 13-02-2020, 05:00 PM
RE: Errors when ending playmode - by TheMunk - 19-02-2020, 12:06 PM
RE: Errors when ending playmode - by josemendez - 19-02-2020, 12:15 PM
RE: Errors when ending playmode - by TheMunk - 21-02-2020, 10:26 AM
RE: Errors when ending playmode - by josemendez - 21-02-2020, 11:18 AM
RE: Errors when ending playmode - by TheMunk - 21-02-2020, 12:15 PM
RE: Errors when ending playmode - by josemendez - 21-02-2020, 01:36 PM
RE: Errors when ending playmode - by TheMunk - 21-02-2020, 02:11 PM
RE: Errors when ending playmode - by TheMunk - 25-02-2020, 12:22 PM
RE: Errors when ending playmode - by josemendez - 25-02-2020, 12:35 PM
RE: Errors when ending playmode - by TheMunk - 25-02-2020, 04:09 PM
RE: Errors when ending playmode - by josemendez - 25-02-2020, 04:35 PM
RE: Errors when ending playmode - by TheMunk - 26-02-2020, 09:31 AM
RE: Errors when ending playmode - by TheMunk - 02-03-2020, 10:24 AM
RE: Errors when ending playmode - by TheMunk - 02-03-2020, 04:16 PM
RE: Errors when ending playmode - by josemendez - 09-03-2020, 11:00 AM
RE: Errors when ending playmode - by TheMunk - 09-03-2020, 08:52 AM
RE: Errors when ending playmode - by josemendez - 09-03-2020, 11:01 AM
RE: Errors when ending playmode - by TheMunk - 28-02-2020, 02:37 PM
RE: Errors when ending playmode - by TheMunk - 14-02-2020, 02:44 PM