Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rolling sphere over generated mesh
#1
Hello again,

I have a generated mesh as seen in the image.. and a rolling sphere on it (constantly pushed forward by AddForce).
The problem is, it seems the mesh might have some small bumps, causing the sphere to "jump" from time to time.
I've noticed unchecking "Optimize" in the Shape Extrusion on the generator diminishes the problems, but it's not perfect.

Any ideas on what to change to make it more smooth?

P.S. I cannot show the bumps in the image, they are hard to see.

[Image: 555jEE.png]
Reply
#2
Before seing else I doubt there are actually bumps in the generated mesh, so it might be a combination of some large triangles (due settings) and the controller code that results in a bumpy movement. Would you mind to send me the scene (preferrable by mail to jake@fluffyunderware.com), I'll have a look then.
Reply
#3
Thank you very much for the solution provided over email.
I do have another problem now I really hope you can help me with.

I have to keep generating road (and delete the parts behind me) and I've found it simple to just instantiate a new CurvySpline (from prefab) to continue the road and later on delete the spline behind. This however leads to two problems:
- when instantiating the new spline, it stutters for a second (on PC and my target is mobile)
- the point where I want the two splines to join, looks like this:

[Image: uh9qfT.png]

Do you know how I can fix these problems? Maybe I should do it some other way, like adding to/removing from a single spline?

Thanks a lot,
Ioan Marcu
Reply
#4
You should connect those splines to get around the gap. To prevent stutter (it's a result from instantiation, which triggers building cache of the new spline, creating the mesh etc..), you should rethink the need to continously add parts and delete them afterwards. Is there a particular reason why you need to?

I would create the whole track at level start by joining all prefabs into a single spline, then running CG over it to generate the mesh. For performance reason, you should enable "Split mesh" to create a series of small meshes. They will get culled by Unity then and/or you can enable&disable the meshes then based on some logic.
Reply
#5
Well, creating the whole track is not really an option, because it is endless.
Reply
#6
Another idea: add/remove Control Points dynamically, and have your CG path input ranged.
Reply
#7
I remember trying that first, but when deleting the first control point (spline.Segments[0].Delete() I believe) I got an error.
Will try again and see! Thanks.
Reply
#8
So I am now trying to add/remove CPs to a single spline.
The adding part works ok and also settings the range for the CG input path - but at least in the editor there's a stutter when doing this still. Not sure if the number of CPs  added at once is important, didn't test much yet on this.
Trying to remove CPs however always brings me to this error.

Code:
NullReferenceException: Object reference not set to an instance of an object
FluffyUnderware.Curvy.CurvySplineSegment.get_ControlPointIndex () (at Assets/Packages/Curvy/Base/CurvySplineSegment.cs:1065)
FluffyUnderware.Curvy.CurvySplineSegment.System.IComparable.CompareTo (System.Object obj) (at Assets/Packages/Curvy/Base/CurvySplineSegment.cs:2757)
System.Collections.Generic.Comparer`1+DefaultComparer[FluffyUnderware.Curvy.CurvySplineSegment].Compare (FluffyUnderware.Curvy.CurvySplineSegment x, FluffyUnderware.Curvy.CurvySplineSegment y) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Comparer.cs:84)
Reply
#9
I already came across the above error while working on an example scene a few days ago. It's already fixed for 2.0.3, shipping very soon.
Reply
#10
Well that's good! Hope to get 2.0.3 soon.
I really have problems with the time it takes to refresh the mesh generation..
What I am doing now is (at some given point in time) add some new control points and refresh spline, modify (extend) CG input path range to include new CPs and then refresh it.
Is it possible to somehow not refresh the entire generated mesh, but just part of it (obviously where the new CPs are)?
Also, is it possible to split the refresh process over multiple frames and not have the entire mesh generated at the same time? Maybe something like split the process after each mesh piece is generated.

Thank you for your help!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Adjust radius of generated mesh via script? Shackman 1 3 03-26-2024, 01:12 PM
Last Post: _Aka_
  Not seeing mesh extended after following YT PaulM 1 3 02-02-2024, 12:01 PM
Last Post: _Aka_
  Trigger Zones along Spline Mesh dlees9191 1 5 01-05-2024, 10:18 AM
Last Post: _Aka_
  Get spline from generated mesh beartrox 1 5 11-27-2023, 12:30 PM
Last Post: _Aka_

Forum Jump: