Posts: 14
Threads: 6
Joined: Jun 2020
Hey guys, I Need some help regarding curvy, I'm trying my best to learn, but the documentation is so well documented it's very overwhelming!
So I've created a spline generated path for a racing game and..
1. I want to know How I Create a custom a custom CG Volume Controller so I can move objects along the path, with random deviation from the center of the spline considering these objects are rigidbodies that should detect collisions and deviate from their movement(I should be able to push them off the spline mesh) when collided.
2. How Can I generate Prefabs facing the direction of the path(tangent) at equal intervals.
I've only been programming for a few months now, so I have a good grasp of the fundamentals and everything, and I'm doing my best to learn as much as possible.
Sorry If I seem to ambitious, the video tutorials helped a lot but the documentation is hard to keep up with. Any Help would be really Appreciated! Thank you in advance.
Posts: 2,113
Threads: 92
Joined: Jun 2017
Hi,
I will answer the first point later, it is very late here.
About the second point:
You can use the Curvy Generator (CG for short), through the editor or the API, to place objects along a spline or volume. You can see example scene: 22_CGClonePrefabs
Another solution that does not use CG: https://forum.curvyeditor.com/thread-627.html
The API changed a bit since that post, but it is still helpfull
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: 14
Threads: 6
Joined: Jun 2020
Thank you! Looking forward to the answer of the first point.
Posts: 2,113
Threads: 92
Joined: Jun 2017
(06-28-2020, 11:09 PM)linkinballzpokemon Wrote: 1. I want to know How I Create a custom a custom CG Volume Controller so I can move objects along the path, with random deviation from the center of the spline considering these objects are rigidbodies that should detect collisions and deviate from their movement(I should be able to push them off the spline mesh) when collided. You can do that without creating a custom volume controller. You can use a similar setup to the example scene 21_CGExtrusion, but instead of setting game over to true when touching an object, you can deactivate the volume controller, so it does not control the position of the object, and use your own code or physics to move the object. In the example the collider is a trigger, you probably want to set that to false.
If you still feel need to have a custom controller, take a look at this: https://forum.curvyeditor.com/thread-580-post-2030.html#pid2030
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 14
Threads: 6
Joined: Jun 2020
(06-29-2020, 07:51 PM)_Aka_ Wrote: (06-28-2020, 11:09 PM)linkinballzpokemon Wrote: 1. I want to know How I Create a custom a custom CG Volume Controller so I can move objects along the path, with random deviation from the center of the spline considering these objects are rigidbodies that should detect collisions and deviate from their movement(I should be able to push them off the spline mesh) when collided. You can do that without creating a custom volume controller. You can use a similar setup to the example scene 21_CGExtrusion, but instead of setting game over to true when touching an object, you can deactivate the volume controller, so it does not control the position of the object, and use your own code or physics to move the object. In the example the collider is a trigger, you probably want to set that to false.
If you still feel need to have a custom controller, take a look at this: https://forum.curvyeditor.com/thread-580-post-2030.html#pid2030
Thanks for the reply, But after a collision I tried your idea and disabled the CG Volume controller script, but the object doesnt react to the collision, for example if I bump into the car from behind it just stops, But I want it to like react to the collision like other ordinary rigid bodies do, How can I achieve this?
For example if I drive into a simple rigidbody cube, it will get pushed in the direction of the collision and get knocked back without any additional setups due to the physics system, but when I try a similar thing with the car in the example scene 21_CGExtrusion, It just doesnt work. How can I do that?
Posts: 2,113
Threads: 92
Joined: Jun 2017
CG Volume Controller, as all controllers, can have their behavior summarize to: updates the object's transform every frame. The moment it updates the transform depends on how you configure it (can be in Update, LateUpdate or FixedUpdate).
So controllers don't disable or stop the physics from running, but potentially override (depending on order of execution) the transform's update done by physics. You just have to test what runs first in your project (adding logs is helpful) and come up with a solution accordingly (changing order of execution, changing the updating method used by the controller, disabling the controller at the right time, ....)
To not be overwhelmed, you can start testing with a simple script instead of a controller, for example a script that each frame override's makes a object move in a circle.
I hope this helped
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 14
Threads: 6
Joined: Jun 2020
(06-30-2020, 03:39 PM)_Aka_ Wrote: CG Volume Controller, as all controllers, can have their behavior summarize to: updates the object's transform every frame. The moment it updates the transform depends on how you configure it (can be in Update, LateUpdate or FixedUpdate).
So controllers don't disable or stop the physics from running, but potentially override (depending on order of execution) the transform's update done by physics. You just have to test what runs first in your project (adding logs is helpful) and come up with a solution accordingly (changing order of execution, changing the updating method used by the controller, disabling the controller at the right time, ....)
To not be overwhelmed, you can start testing with a simple script instead of a controller, for example a script that each frame override's makes a object move in a circle.
I hope this helped
I think I'm going to use my own follow script for now, this seems overly complicated for me.
So I have a generated a bunch of gameobjects to act was waypoints. How I can get these waypoints gameobjects as an array or list via script?
specifically the exact line of code would be very helpful with the necessary reference.
Posts: 2,113
Threads: 92
Joined: Jun 2017
Not sure what you are asking about, but here are some information that I hope do answer your question. I am assuming that you want to get the position and tangent of points on a spline to position your objects accordingly: - To get data about a single arbitrary point, use CurvySpline's Interpolate, GetTangent and GetOrientation's family of methods
- To get data about the cached points, use CurvySpline's Interpolate, GetApproximation family of methods
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 14
Threads: 6
Joined: Jun 2020
Sorry if i wasn't clear, let me rephrase. So i have generated prefabs along my spline similar to 22_CGClonePrefabs scene. Now i want to store these generated prefab gameobjects in an array. How can i store these generated prefabs in an array ordered from start of spline to the end of the spline?
Posts: 2,113
Threads: 92
Joined: Jun 2017
There are a couple of ways, the simplest being to use Unity'API to get the list of the children of your Create GameObject module. The order of creation of those items is the same than the order of their names, which is from start of spline to its end.
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
|