Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making long roadmesh runtime
#1
hi. i am able to create roadmesh at runtime with my player controller but this gets pretty heavy for pc because everytime i add a new segment, it updates whole road. 
how can i make new segments without updating the whole road? do i need to create new spline that continues from previous one? if so, how can i do that?

it seem that creating new generators at runtime is pretty heavy so i try to use one generator and add new spline to it. however i need to access generators InputSplinePath node to add spline there. 
i tried to access node with this code: InputSplinePath isp = generator.GetModule<InputSplinePath>(moduleID); isp.Spline = newSpline;
but isp is null. i dont know why. the node is there

tl;dr: how can i make long roads without updating the whole road everytime i add new segment to it

https://i.imgur.com/hyZ5KPu.png

this is how i get that moduleID. i create that generator when game starts. i dont know if this is correct way to get it.
Reply
#2
update:

now i can access the node by making public InputSplinePath variable and giving it value in that buildGenerator function. now i can make new spline with same generator. but when i create new spline and assign spline to generator, previous road mesh disappears because it has no generator anymore. i can keep old road visible by copying the mesh before it disappears but this feels a bit hacky and i dont know if im doing this right
Reply
#3
Hi,

1- GetModule probably returns null because the second (optional) parameter is set to false
2- If you haven't read it yet, I recommand you to read this page: https://curvyeditor.com/documentation/performancetips
3- You can have two generators one for each spline. If you want to keep one generator, your solution is valid. You can also use directly the CreateMesh.SaveToScene method.

Please let me know if you have any other questions. Also keep me updated about whether you reached satisfying performance.
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
#4
ok. how do i get the spesific node id when i create generator in scene (not with code)? can you perhaps give me an example code on how to get some node from generator with code?
and what is CGMeshResource.cs? is it important? its on the road mesh it generates. can i delete it safely after mesh is created?

thanks
Reply
#5
CGMeshResource is a script used by the Curvy Generator to manage the life time of meshes. The CreateMesh.SaveToScene method gets rid of all those scripts used solely by the Curvy Generator.

CGModule.UniqueID is the property 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.
Reply
#6
hi road is now working properly. i have another question Big Grin

is there a way to get spline position from world point? for example. i raycast to some point of road and road returns splinecontrollers absolute position for me
Reply
#7
SplineController.Spline to get the spline
CurvySpline.GetNearestPointTF to get the TF
CurvySpline.TFToDistance to convert it to distance
SplineController.AbsolutePosition to set the distance
You can see some of those methods used in example scene 04_PaintSpline, in the script it uses named MoveToNearestPoint
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#8
thanks!

ps. i gave 5 stars on asset store Smile
Reply
#9
Thanks a lot Smile
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#10
hi again. i set my road generator to my game and i am getting pretty huge lag spikes when i finish creating the road (see pic https://i.imgur.com/Kss23Nx.png). previously i had empty scene so i didnt notice much.

everything is working fine except the spike after road is created. im using CreateMesh.SaveToScene() too
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Avoiding runtime GC allocations on control point position change Ell223 8 18 02-24-2024, 10:43 AM
Last Post: _Aka_
Wink Modifying Splines at Runtime artsung 1 7 01-30-2024, 09:40 AM
Last Post: _Aka_
  Is it possible to create a road texture at runtime? artsung 1 4 01-30-2024, 09:30 AM
Last Post: _Aka_
  Cant Generate Meshes At Runtime alms94 5 22 01-26-2024, 11:27 AM
Last Post: _Aka_

Forum Jump: