Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Performance issues
#5
(20-08-2019, 07:25 PM)josemendez Wrote: From the profiler pics, I can tell two things:

- Rope rendering is taking up too much time. If you're using the extruded rope renderer, try using a less dense rope section asset, maybe 4 or 5 segments are enough instead of the default 8. You can also use the LineRenderer instead, as it is much cheaper than the extruded one. See: http://obi.virtualmethodstudio.com/tutor...modes.html

- Your scene has a bad case of death spiralling. FixedUpdate() is being called 5 times per frame (see the "calls" column in the profiler),  ideally it would be called only once. Good news is things can run at least 5 times faster than they currently are. Try lowering Unity's max fixed timestep, to a small multiple of the fixed timestep (if fixed timestep is set to 0.02, use a max of 0.04 for instance). You can find these settings in the Time Manager: https://docs.unity3d.com/Manual/class-TimeManager.html

Death spiralling can take place in any fixed-timestep engine, not just Unity. So if you're making games where physics play an important role, it is crucial you understand what it is and why it happens, as it can very easily kill your performance.

Alright so I have tried using 4 segments and weird enough it has 0 impact on fps, it literally didn't do anything not noticeable with 1 rope anyway. I do thank you for pointing out the death spiralling thing, I have been reading up on it and that was quite interesting although it didn't change much performance wise for my game, apparently the right time was 0.03 for me. So how would I go about implementing the rope using the linerenderer because wouldn't that mean that the rope is just going to be completely straight? Also my rope is always kind of flat or more or less like an oval shape, is this intended and maybe it has anything to do with my current issues? Maybe the code that generates my rope is just bad?

This is the code that I use to generate ropes:

Code:
public IEnumerator MakeRope(Transform fromtrans, Transform totrans, float ropeLength)
   {
       GameObject ropeObject = new GameObject("HitchRope", typeof(ObiSolver),
                               typeof(ObiRope),
                               typeof(ObiCurve),
                               typeof(ObiRopeExtrudedRenderer),
                               typeof(ObiRopeCursor));
       ropeObject.transform.position = fromtrans.position;
       rope = ropeObject.GetComponent<ObiRope>();
       path = ropeObject.GetComponent<ObiCurve>();
       solver = ropeObject.GetComponent<ObiSolver>();
       ropeextruder = ropeObject.GetComponent<ObiRopeExtrudedRenderer>();
       cursor = ropeObject.GetComponent<ObiRopeCursor>();
       render = ropeObject.GetComponent<MeshRenderer>();

       rope.Solver = solver;
       rope.ropePath = path;
       ropeextruder.section = Resources.Load("DefaultRopeSection") as ObiRopeSection;
       ropeextruder.section.CirclePreset(4);

       render.material = RopeMaterial;
       
       ropeextruder.uvScale = new Vector2(1, 10);
       rope.thickness = 0.03f;

       yield return rope.StartCoroutine(rope.GeneratePhysicRepresentationForMesh());
       rope.AddToSolver(null);

       GameObject HandleObject01 = new GameObject("Obi Handle01", typeof(ObiParticleHandle));
       HandleObject01.transform.parent = fromtrans;
       GameObject HandleObject02 = new GameObject("Obi Handle02", typeof(ObiParticleHandle));
       HandleObject02.transform.parent = totrans;      

       ObiParticleHandle handle01 = HandleObject01.GetComponent<ObiParticleHandle>();
       handle01.Actor = rope;
       handle01.AddParticle(0, fromtrans.position, Quaternion.identity, rope.invMasses[0], 1);
       handle01.AddParticle(1, fromtrans.position, Quaternion.identity, rope.invMasses[1],1);  

       ObiParticleHandle handle02 = HandleObject02.GetComponent<ObiParticleHandle>();

       handle02.Actor = rope;
       int index = rope.UsedParticles - 1;

       Vector3 hitchpoint = new Vector3(totrans.GetComponent<Collider>().bounds.center.x,
           totrans.GetComponent<Collider>().bounds.center.y + (totrans.GetComponent<Collider>().bounds.size.y / 2),
           totrans.GetComponent<Collider>().bounds.center.z);

       handle02.AddParticle(index, hitchpoint, Quaternion.identity, rope.invMasses[index], 1);
       handle02.AddParticle(index - 1, hitchpoint, Quaternion.identity, rope.invMasses[index - 1], 1);
       rope.AddToSolver(null);


       cursor.normalizedCoord = 0.5f;
       cursor.direction = true;

       cursor.ChangeLength(ropeLength);
   }
Reply


Messages In This Thread
Performance issues - by Smurfj3 - 20-08-2019, 05:07 PM
RE: Performance issues - by josemendez - 20-08-2019, 05:46 PM
RE: Performance issues - by Smurfj3 - 20-08-2019, 06:53 PM
RE: Performance issues - by josemendez - 20-08-2019, 07:25 PM
RE: Performance issues - by Smurfj3 - 20-08-2019, 08:09 PM
RE: Performance issues - by josemendez - 21-08-2019, 04:28 PM
RE: Performance issues - by Smurfj3 - 22-08-2019, 08:59 PM
RE: Performance issues - by josemendez - 23-08-2019, 07:22 AM
RE: Performance issues - by Mancomb - 10-09-2019, 07:59 AM
RE: Performance issues - by josemendez - 10-09-2019, 08:36 AM
RE: Performance issues - by Smurfj3 - 22-10-2019, 04:09 AM
RE: Performance issues - by Smurfj3 - 01-11-2019, 06:28 PM
RE: Performance issues - by StudioTatsu - 03-11-2019, 10:24 PM
RE: Performance issues - by josemendez - 04-11-2019, 02:19 PM
RE: Performance issues - by Smurfj3 - 25-11-2019, 05:05 PM
RE: Performance issues - by Wattosan - 06-12-2019, 09:04 AM
RE: Performance issues - by josemendez - 09-12-2019, 12:22 AM
RE: Performance issues - by Wattosan - 09-12-2019, 12:53 PM
RE: Performance issues - by josemendez - 09-12-2019, 04:23 PM
RE: Performance issues - by Wattosan - 10-12-2019, 12:15 PM
RE: Performance issues - by josemendez - 10-12-2019, 12:28 PM
RE: Performance issues - by Wattosan - 10-12-2019, 01:16 PM
RE: Performance issues - by josemendez - 10-12-2019, 01:37 PM
RE: Performance issues - by Wattosan - 10-12-2019, 02:00 PM
RE: Performance issues - by josemendez - 10-12-2019, 02:42 PM
RE: Performance issues - by Wattosan - 10-12-2019, 03:43 PM
RE: Performance issues - by josemendez - 10-12-2019, 04:03 PM
RE: Performance issues - by Wattosan - 11-12-2019, 08:11 AM
RE: Performance issues - by BisuDagger - 10-12-2019, 05:25 PM
RE: Performance issues - by josemendez - 10-12-2019, 05:39 PM
RE: Performance issues - by BisuDagger - 10-12-2019, 05:47 PM
RE: Performance issues - by josemendez - 10-12-2019, 06:01 PM