Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
instantiate Spline Controller at runtime
Hi all,

Please could someone point me in the right direction?

I have a script that instantiates a gameobject with a spline controller attached.
Is there a way of telling this gameobject what spline to use? Iv searched the documentation but cant seem to find an answer.

At the moment it spawns in but cannot associate itself to my spline.

Thanks in advance.
Is this what you are looking for?
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Ok Cross-checking that thread I did manage to figure this out.

For anyone in the future here is my code to make this work.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FluffyUnderware.Curvy.Controllers;
using FluffyUnderware.Curvy;

public class VehicleSpawner : MonoBehaviour
   private SplineController sc;
   public GameObject[] vehicles;
   public float spawnInterval;
   public CurvySpline road;

   private void Start()

   private IEnumerator SpawnVehicles()
       while (true)
           int index;
           index = Random.Range(0, vehicles.Length - 1);
           sc = vehicles[index].GetComponent<SplineController>();
           sc.Spline = road;
           yield return new WaitForSeconds(spawnInterval);

Hope it helps Smile

Possibly Related Threads…
Thread Author Replies Views Last Post
  Scale Deform Mesh Along Spline? / aligning colliders MamasToast 6 31 09-25-2022, 08:47 PM
Last Post: _Aka_
  How can I remove one segment of the road that I made by spline? Chanon 3 6 09-14-2022, 04:44 PM
Last Post: _Aka_
  Force spline normal to be always world up GameJazz 12 22 08-08-2022, 01:20 PM
Last Post: _Aka_
  Gap between spline mesh segments Beaver_Boy 8 22 08-06-2022, 12:11 PM
Last Post: _Aka_

Forum Jump: