Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Set random spline to object
#1
Hi!!!
I have several splines in my scene and prefabs of my GameObjects with FollowSpline script attach on them.  All i want is to instantiate my object(randomly) once per second on start position one of this splines(randomly), run on it and delete when it comes to the end of this spline.
I have GameManager script with two arrays of spline and objects:

public class CarsManager : MonoBehaviour
    {
        public MyFollowSpline myFollowSpline;
        public float spawnTime = 3f;       
        public GameObject carItems;
        public CurvySpline splinesToFollow;
    
        void Start ()
        {
            InvokeRepeating ("Spawn"spawnTimespawnTime);
        }
    
        void Spawn ()
        {
            int spawnSplineIndex = Random.Range (0splinesToFollow.Length);
            int spawnCarIndex = Random.Range (0carItems.Length);
            CurvySpline mySpline = splinesToFollow [spawnSplineIndex];
            .......?

        }
    }
The question is how to instantiate GameObject and attach to it one of this spline in my Spawn method? And how to delete GameObject when it comes to the end of the spline(i think this method has to be in FollowSpline script)?

 

 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Information Common reasons why your spline gizmo is invisble _Aka_ 0 0 05-20-2022, 03:56 PM
Last Post: _Aka_
  Connect two spline at runtime Doomchecker 2 6 05-18-2022, 04:12 PM
Last Post: Doomchecker
Exclamation Runtime error when using Curvy Generator with Game Object Deform studentloan 3 10 04-22-2022, 09:00 PM
Last Post: _Aka_
Bug No demos running without exception with IL2CPP with Curvy Spline 8 studentloan 10 14 04-22-2022, 08:52 PM
Last Post: _Aka_

Forum Jump: