Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Performance issues
#6
(20-08-2019, 08:09 PM)Smurfj3 Wrote: 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);
   }

Hi there,

I don't see anything wrong with your code at first sight.

Using a ObiRopeLineRenderer won't make your rope straight, it works just like Unity's line renderer: it draws a camera-facing triangle strip, which is quite cheap compared to a full extruded mesh.

Also, always profile the exact same scenario, ie. the one that exhibits performance issues. Using a 4 segment section instead of a 8 segment one will have a negligible impact on just one rope, but the benefit will add up when you have several ropes.
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