Posts: 12
Threads: 2
Joined: May 2019
07-25-2020, 12:33 PM
(This post was last modified: 07-25-2020, 02:59 PM by migeg.)
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.
Posts: 12
Threads: 2
Joined: May 2019
07-25-2020, 02:58 PM
(This post was last modified: 07-25-2020, 02:59 PM by migeg.)
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
Posts: 2,113
Threads: 92
Joined: Jun 2017
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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 12
Threads: 2
Joined: May 2019
07-27-2020, 12:31 AM
(This post was last modified: 07-27-2020, 12:34 AM by migeg.)
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
Posts: 2,113
Threads: 92
Joined: Jun 2017
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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 12
Threads: 2
Joined: May 2019
hi road is now working properly. i have another question
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
Posts: 2,113
Threads: 92
Joined: Jun 2017
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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 12
Threads: 2
Joined: May 2019
08-03-2020, 01:11 PM
(This post was last modified: 08-03-2020, 01:26 PM by migeg.)
thanks!
ps. i gave 5 stars on asset store
Posts: 2,113
Threads: 92
Joined: Jun 2017
Thanks a lot
Please consider leaving a
review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 12
Threads: 2
Joined: May 2019
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