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 Splines, this helps immensely. Thank you.
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
  Spline Spots from 2 samples. BitBlit 8 655 06-30-2026, 11:49 AM
Last Post: _Aka_
  Best way to duplicate a spline with an offset Kapistijn 8 2,067 04-12-2026, 03:18 PM
Last Post: _Aka_
Smile Constant speed along a spline? tfishell 1 867 11-13-2025, 11:32 AM
Last Post: _Aka_
  Create Game Object Renaming Options rickgplus 1 1,104 09-23-2025, 09:33 AM
Last Post: _Aka_

Forum Jump: