Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can Curve Spline be used for an in game level editor.
#1
Like the title suggests, I'm trying to create an in game spline block placement editor. 

The general idea is to allow creation of walls and towers. Towers would be placed where spline nodes are, while walls would fill the spaces between.

You can draw a line segment with a start and end tower point on the map. When close to another existing wall, it can snap. If your close to a node, it'll merge the two lines together, if your not close enough, it'll just attach the wall to that position.

The catch is that I need to allow both the walls to spawn as their own objects to allow for destruction. (basically each wall is a block / segment that can be destroyed.)
I also ideally want the walls to be able to curve towards the spline if needed.

In general the castle walls will be straight, but I do want to allow the ability to curve the walls by click the wall segment and dragging out.


Another side question was if it is possible to add junctions (to connect multiple different splines) and is it possible for a spline to connect to itself (for something like a figure 8 railroad track)

I've been having so much trouble using different spline apis, trying to hack / write them to work for my needs and its just been so frustrating. My most recent attempt was the closest but it was glitchy and its performance wasn't good at all. 


I proved an image of what I'm trying to achieve. 

Is it possible to do what I want with this, and is it complicated to pull off? I've been so demoralized this past month and a half, and I'm desperate for a better solution.


Attached Files Thumbnail(s)
   
Reply
#2
Hi

Curvy Splines is usable via the Unity editor through Curvy's UI. That UI uses Curvy's API behind the scenes. So if Curvy's UI can do it, then a runtime UI can do it too.
Please keep in mind that Curvy Splines do not provide a UI outside the editor. So for an in-game level editor, you will have to code your own level editor UI (which will use Curvy's API to apply the changes).

From my understanding of what you try to do, yes it is doable via Curvy Splines' API. If you use Curvy Splines and find yourself not able to achieve your goal, please contact me. If I can't provide a solution to your issue in a reasonable time, then feel free to ask for a refund.

For more information:
The asset's documentation: https://curvyeditor.com/documentation/start
The API reference: https://api.curvyeditor.com

The classes for:
A spline: Curvy Spline
A segment/node: Curvy Spline Segment
A junction/connection: Curvy Connection

I hope this helped.

Have a great 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
#3
That's great to hear. Is it possible to have generated objects be placed on nodes/points only, and have other generated objects only create between nodes?

Also can nested child objects be curved?
Reply
#4
(05-01-2023, 04:43 PM)Lupos Wrote: That's great to hear. Is it possible to have generated objects be placed on nodes/points only, and have other generated objects only create between nodes?

Placing objects on the node is simple, since every node is its own GameObject, you can simply iterate through them via script and place your game objects.
For placing objects in between, you can either
  • do it via script. The main methods you will need are CurvySpline.InterpolateByDistance and CurvySplineSegment.Length. Using these methods, you can find the position of points on the spline at equal distance from each other.
  • use the Curvy Generator (using the Volume Spots module). This module offers a lot of options when it comes to placing objects on a spline.
    Here is a tutorial showing how to use the generator for that usage: https://youtu.be/jUrpY9-8xH4
    Here is the documentation of said module: https://curvyeditor.com/documentation/generator/modules/volumespots 


(05-01-2023, 04:43 PM)Lupos Wrote: Also can nested child objects be curved?
Yes they can. In this tutorial, at the moment specified in the link, you can see that the RailBlock object has nested game objects: https://youtu.be/eP6QEn9SFoM?t=383
The scene in the tutorial is part of the package.

Hope this helped.
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
#5
Quote: use the Curvy Generator (using the Volume Spots module). This module offers a lot of options when it comes to placing objects on a spline.

I've taken a look at the Volume Spots module and played around with it. So far its really fantastic and seems to run much faster then what I was using before.

I still can't seem to figure out the best way to have the generation only create stuff in between points. I see that I can limit where it generates stuff like the Volume Path Range as well as the spline input path range, but that doesn't really solve my issue of only spawning stuff in between two points (or segments.)
I also looked at group to see if there was anything I could adjust or add. (it'd be cool to be able to control things in the groups maybe i dunno)

Is there an easy built in way to just spawn objects inbetween points? of a segment with this?

Seems like the only thing I can do is create a new spline path, set the control points to be the segment i need, then rasterize it... and then i can either set the range during the rasterization, or do it in the spots volume. 
I'm just not sure if that's performant. 

I tried referencing the same spline path via different inputs, and setting the settings there. Maybe I can find a way to get that work. But if I did, I'd have multiple spline inputs all linking to the same original reference spline. And then each of those would be rasterized, and then spots volume.


Also as a follow up is it possible to retain a prefabs scripts? The curvable objects I'm trying to create require having logic applied to them for destruction, so far I cant seem to get that to work with the generator.

Edit* I'm starting to think I'll have to script this like u originally suggested.

Edit** If going the coding wrote, how can i get objects to curve towards the spline.

Thanks for taking the time to help out.
Reply
#6
(05-02-2023, 08:09 PM)Lupos Wrote: Is there an easy built in way to just spawn objects inbetween points? of a segment with this?
 
There is no specific option to spawn just in between CPs, but ...

(05-02-2023, 08:09 PM)Lupos Wrote: Seems like the only thing I can do is create a new spline path, set the control points to be the segment i need, then rasterize it... and then i can either set the range during the rasterization, or do it in the spots volume. 
I'm just not sure if that's performant. 

I tried referencing the same spline path via different inputs, and setting the settings there. Maybe I can find a way to get that work.
  

... you can indeed have multiple input modules, all using the same spline, but each one of them having a different couple of Start/End CP : https://curvyeditor.com/documentation/generator/modules/inputsplinepath#range
Setting up these different modules can be done via API. The method FluffyUnderware.Curvy.Examples.E51_InfiniteTrack.buildGenerator does that, if you need an example.

(05-02-2023, 08:09 PM)Lupos Wrote: But if I did, I'd have multiple spline inputs all linking to the same original reference spline. And then each of those would be rasterized, and then spots volume.
  
There nothing fundamentally wrong with this, the amount of duplicated calculations is relatively small.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#7
(05-02-2023, 08:09 PM)Lupos Wrote: Also as a follow up is it possible to retain a prefabs scripts? The curvable objects I'm trying to create require having logic applied to them for destruction, so far I cant seem to get that to work with the generator.

go to FluffyUnderware.Curvy.Generator.CGMeshResourceLoader.Destroy. There, find this:
Code:
                    obj.StripComponents(
                        typeof(CGMeshResource),
                        typeof(MeshFilter),
                        typeof(MeshRenderer)
                    );
and replace it with
Code:
                    obj.StripComponents(
                        typeof(CGMeshResource),
                        typeof(MeshFilter),
                        typeof(MeshRenderer),
                        typeof(your_script)
                    );
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
(05-02-2023, 08:09 PM)Lupos Wrote: Edit** If going the coding wrote, how can i get objects to curve towards the spline.

I assume that this question means: How to make an object, which position you specify,  be deformed following a spline. Correct me if I am wrong.
The mesh deformation is done via the Deform Mesh module. That volume needs a Spots input, that defines the transform of the deformed mesh. The issue is that the Volume Spots does not implement placement rules that you want. So you have multiple choices:
  1. Modify the Volume Spots module (class: BuildVolumeSpots) to make it implement your logic. Not the easiest one.
  2. Make a new module that generates spots using your own logic. A wizard will help you create a module's skeleton at Project's window→Create→Curvy→CG Module. Not that complicated, but not that simple. You will most probably need to take a look on a simple spots generating module (such as Spots, class: InputSpots).
  3. Make a script, that is not a module, that will populate an existing Spots module (class: InputSpots). This module is basically a list of spots. This is the simplest solution.

FYI: the method that does the mesh deformation is DeformMesh.DeformMeshes. It is a public static method. This means that you can use in whatever code you want. I don't believe you will have to, but I am letting you know just in case.

(05-02-2023, 08:09 PM)Lupos Wrote: Thanks for taking the time to help out.
You are welcome
If and when you feel like it, please leave a review for the asset, that helps a lot.
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
#9
So if I'm not mistaken the easiest solution would be to use the Generator. And then either spawn multiple spline rasterizers (which are between the points I need) that feed into spot modules? 
Or modify 1 spot module directly and fill that with the data I need by figuring out manually the spaces between the points I need?

Which would you recommend overall? 

Edit* In the createGenerator example, are the generators automatically pooled? Or is that something I'll need to take care of?
Edit** When using my own prefabs with their own logic, is it possible to call specific functions on generation? Or do I move logic into OnEnable of the component?
Edit*** I keep getting a "The given key "Path" was no present in the dictionary. For the volume spots module when I try connecting the InputPath's "Path". No matter what combination of "Path" or "Volume" I'd try would result in the error.
(Turns out you have to use "Path/Volume") The documentation made it seem like either or is fine. Or that Volume/Path would work. My bad.

Incredible support thank you so much, I'll be sure to leave a solid review.
Reply
#10
I also had 1 follow up question regarding building in between points. I know you suggested calculating the distance but I'm having trouble knowing how I'd limit it.
I'm simply trying to make it so that for the size of my placed object (in this case its 1 unit) dont build anything at the start and end node of a segment.

I tried figuring out how to take the Distance and subtract .5f (half a unit) from it, and then converting that into a localDistance for the segments but I'm having trouble getting it correct.

It seems the generation spawns stuff starting from the first node, to the next node. Ideally I'm trying to find a way to almost essentially generate it from the center, outward to each point. However I don't really need that, I just need to make sure the start and end points don't create anything within half a unit from each point.

I provided an image below of what I'm trying to do. 

Each point is 1 unit, and then every block placed between the segment is 1 unit. I need them to fit between the points as best they can. This way the desctruction system can have towers and walls break without any intersections.


Attached Files Thumbnail(s)
   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  snap to the curve created by the curvy splines segment points ShiroeYamamoto 0 0 4 hours ago
Last Post: ShiroeYamamoto
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 13 03-04-2024, 11:06 AM
Last Post: _Aka_
  Keeping a fixed spline length jh092 3 16 02-21-2024, 06:25 AM
Last Post: Primrose44

Forum Jump: