Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best practice for mass-object instancing along 100km spline (railways) plus streaming
#5
4- I ended up writing that custom script. It took 2.5s to instantiate the 200.000 seconds. The script is very minimalistic. Any customization should be done via code. It instanciates the objects at every cache point of the spline. Here it is:

Code:
using FluffyUnderware.Curvy;
using UnityEngine;

public class TTT : MonoBehaviour
{
   public GameObject GameObject;
   public CurvySpline Spline;

   void Start()
   {
       //int count = 0;
       for (int segmentIndex = 0; segmentIndex < Spline.Count; segmentIndex++)
       {
           var segment = Spline[segmentIndex];
           for (var cachePointIndex = 0; cachePointIndex < segment.Approximation.Length; cachePointIndex++)
           {              
                GameObject.Instantiate(GameObject, segment.Approximation[cachePointIndex], Quaternion.LookRotation(segment.ApproximationT[cachePointIndex]));

               //count++;
           }
       }
       //Debug.Log(count);

   }
}

The code executes at Start for my test purpose. Feel free to make it execute elsewhere
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Messages In This Thread
RE: Best practice for mass-object instancing along 100km spline (railways) plus streaming - by _Aka_ - 09-06-2019, 11:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 14 03-04-2024, 11:06 AM
Last Post: _Aka_

Forum Jump: