Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Move spline attached to gameobject.
#1
Hey,

I'm new to using Curvy but I haven't been able to find how one would move a spline in realtime along with a Gameobject. (and if possible, animated)
Example:
I have a crane, with a rope using Curvy, control points are on top of the crane. Moving/rotating the crane will not move my CurvySpline (which is a child).
The Curvyspline gizmo seems to move along but the generated mesh doesn't.

Hierarchy as follows:

Machine
-Crane (has animation)
--CurvySpline
---ControlPoint
---ControlPoint

I've tried just making another Gameobject, attaching a Curvyspline to it and moving the Gameobject. The generated mesh stays put. Can't seem to make my meshes move along their parent..

Is this at all possible? It seems like a no-brainer to have this so I might have just missed it.

Thanks in advance
Reply
#2
If you set the Curvy Generator also as a child of the crane, your will get the behavior you expect.

The reason behind the behavior you are facing is that Curvy Generator uses the local positions of the input splines. So when you move the crane, the world position of the control points changes, but their local positions stay the same, thus the generated mesh stays the same.
When the input splines and the generator have the same parent, or even better, the spline is a child of the input spline module, like in the generator's "Shape Extrusion" template, the issue does not appear because moving/rotating the generator will also move/rotate the generated mesh.

Does my answer indeed fix your issue?
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
(01-24-2018, 12:23 PM)_Aka_ Wrote: If you set the Curvy Generator also as a child of the crane, your will get the behavior you expect.

The reason behind the behavior you are facing is that Curvy Generator uses the local positions of the input splines. So when you move the crane, the world position of the control points changes, but their local positions stay the same, thus the generated mesh stays the same.
When the input splines and the generator have the same parent, or even better, the spline is a child of the input spline module, like in the generator's "Shape Extrusion" template, the issue does not appear because moving/rotating the generator will also move/rotate the generated mesh.

Does my answer indeed fix your issue?

Yes! Thank you!

Is there a way to make this more performant? When animating this in unity there's lagg when playing this in the editor. And this is just two points being animated. The lagg stops when turning the generator off.

In play mode it laggs behind a bit. When the animation resets it resets one frame later.
Reply
#4
Regarding the performance, I will take a look at this and answer you later.
Regarding the generator being one frame behind, I couldn't reproduce the issue with my test scene, so the solution I am going to give you is not tested: try set the spline "Update In" setting of your splines to Late Update.


Attached Files Image(s)
   
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
(01-24-2018, 02:14 PM)_Aka_ Wrote: Regarding the performance, I will take a look at this and answer you later.
Regarding the generator being one frame behind, I couldn't reproduce the issue with my test scene, so the solution I am going to give you is not tested: try set the spline "Update In" setting of your splines to Late Update.

Thanks!
I'm afraid Late update doesn't do the trick.

Here's a gif showing the lagg-behind in the rope and then the extra frame at the end:

https://i.imgur.com/zxEtOEM.gifv
Reply
#6
In this post, I will give an explanation to your performance issues, and then a workaround.

The explanation: The curvy generator does virtually nothing until one of its inputs changes, at which point  it generates the related data. In your case, changing the world position or rotation of the spline makes the spline notify the generator that it has changed, even if the changed information (the world position) is irrelevant to the generator, thus making the generator regenerate everything at each frame. I need to work on a smarter way to keep track of changes, one that makes the distinction between irrelevant changes and relevant one. So until such thing is released in an upcoming update, here is ...

The workaround: Disable the "Check Transform" setting in your splines. This will stop the splines from being updated automatically  (in play mode). You will then need to make them update whenever you change their shape by calling the Refresh() method. Here is an example where I update the position of the last point of a spline:
Code:
curvySpline.ControlPoints.Last().localPosition += Vector3.forward;
curvySpline.Refresh();

Your issue with the spline lagging by one frame might also be fixed by the Refresh call.

If you still have performance issues, and made sure you don't generate unnecessary data for your use case (colliders, normals, tangents, etc), you can send me one of your scenes so I can profile it and pinpoint where the performance issues come from.
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
Curvy 2.3.0, which should be available on the store in a couple of days, includes a fix to the issue you described
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
  Find if object is on spline path nciofi 1 45 07-10-2018, 09:23 AM
Last Post: _Aka_
  Spline Approximation List skyboard 2 73 07-01-2018, 11:02 PM
Last Post: _Aka_
  Freeing objects from a spline Renald 1 77 06-20-2018, 11:10 AM
Last Post: _Aka_
  Spawn Objects of differing lengths uniformly along a Spline taylor 1 101 06-19-2018, 05:31 PM
Last Post: _Aka_

Forum Jump: