Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Set Volume to the Volume Controller at Runtime
#1
I have a "Kart" with the Volume Controller. I want to use it in different scenes, in which I have created Tracks using CG. There's just one track per scene and the tracks don't change at runtime.

As I understand it, even though I have generated a stand-alone mesh for each Track, I'll still need to have the Curvy Generator hierarchy game objects active, but without the "Create Mesh" module, as the mesh has already been created. This way, I can find a reference to the created volume for the Track in individual scenes.

So, to set the Volume in the Volume Controller, I'll search using a tag for the game object having either the BuildShapeExtrusion or the BuildShape component. However, I haven't succeeded in getting a reference to the Volume by having a reference to these components. Obviously, I'm not doing it the right way.

I'd really appreciate it if you could tell me how to achieve this, so I can set the Volume to the Volume Controller after each scene is loaded.

Thank you!
Reply
#2
(04-08-2024, 10:17 AM)pako88 Wrote: I have a "Kart" with the Volume Controller. I want to use it in different scenes, in which I have created Tracks using CG. There's just one track per scene and the tracks don't change at runtime.

As I understand it, even though I have generated a stand-alone mesh for each Track, I'll still need to have the Curvy Generator hierarchy game objects active, but without the "Create Mesh" module, as the mesh has already been created. This way, I can find a reference to the created volume for the Track in individual scenes.

So, to set the Volume in the Volume Controller, I'll search using a tag for the game object having either the BuildShapeExtrusion or the BuildShape component. However, I haven't succeeded in getting a reference to the Volume by having a reference to these components. Obviously, I'm not doing it the right way.

I'd really appreciate it if you could tell me how to achieve this, so I can set the Volume to the Volume Controller after each scene is loaded.

Thank you!


I figured it out:

Code:
                GameObject shapeExtrusionGameObject = GameObject.FindGameObjectWithTag("ShapeExtrusion");
                BuildShapeExtrusion buildShapeExtrusion = shapeExtrusionGameObject.GetComponent<BuildShapeExtrusion>();
           
                volumeController.Volume = new CGDataReference(buildShapeExtrusion, "Volume");
Reply
#3
Hi,
Glad to read that you found the solution. Feel free to ask if you have other questions.
Have a nice day.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Volume Spots inter group distance Sacryn 1 3 02-27-2024, 04:08 PM
Last Post: _Aka_
  Avoiding runtime GC allocations on control point position change Ell223 8 18 02-24-2024, 10:43 AM
Last Post: _Aka_
  Add noise to spline controller movement DekoGames 2 10 02-06-2024, 01:28 PM
Last Post: DekoGames
Wink Modifying Splines at Runtime artsung 1 7 01-30-2024, 09:40 AM
Last Post: _Aka_

Forum Jump: