Posts: 3

Threads: 1

Joined: Mar 2019

I'm attempting to build a basic vehicle controller to use on curvy splines. It's nothing fancy and doesn't require realistic physics. In fact it is more similar to a pseudo 3d racing controller such as OutRun or RoadRash. My tracks are built with the supplied volume generators and I have enough understanding to manipulate the position and speed along the spline, as well as move my object left and right across the cross range. (Basically I have no problem recreating example 21 Extrusion).

I would however like to apply a basic centrifugal force to my object based on how sharp the turn is (so it doesn't turn corners automatically), but I'm not sure where to start or how to grab that data from the spline as I have never worked with Curvy before.

Any help would be much appreciated.

Posts: 1,148

Threads: 55

Joined: Jun 2017

Hi,

Splines have a tangent at each of their points. So to know how sharp a turn is, compare the tangent of the spline at nearest point to the vehicule with the tangent at let's say half a meter in front of that point.

Here is some helpful documentation

https://api.curvyeditor.com/520/class_fl...28452b53a6
Please consider leaving a

review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.

Posts: 3

Threads: 1

Joined: Mar 2019

Thanks heaps, I had looked through the tutorials, controller scripts, and documentation but neglected to search the API =/. Silly me.

I do have another issue now though.

I would like to apply consistent speed values when shifting left or right across the cross path of the volume no matter how wide my volume is.

My game is going to have tracks with narrow flat paths, wide open roads with lots of room, curved tunnels that vehicles can drive up the walls and onto the ceiling, as well as tubes that vehicles can drive completely around. Curvy works great for this so far due to the cross clamping options provided.

However.....

Currently speed is applied proportionally to length of the cross path. To fix this I would need to find the real world length of the cross path and adjust horizontal speed accordingly. Since I'm using volumes that often loop around I can't just subtract the coordinates of the end of the path from the start as it's the same position and I would get zero.

Is there a function already in Curvy that supplies this length and if so, how would I access it in a script that extends the VolumeController?

Posts: 1,148

Threads: 55

Joined: Jun 2017

What you are looking for is

VolumeController.VolumeData.GetCrossLength(pathF) to get a specific cross's length

or

VolumeController.VolumeData.CrossFToDistance(pathF, crossF) to compute the distance between two different point of coordinates (pathF, crossF1) and (pathF, crossF2)

Did that help?

Please consider leaving a

review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.

Posts: 3

Threads: 1

Joined: Mar 2019

03-07-2019, 12:58 AM
(This post was last modified: 03-07-2019, 05:51 AM by Mighty183.)
(03-06-2019, 12:13 PM)_Aka_ Wrote: What you are looking for is

VolumeController.VolumeData.GetCrossLength(pathF) to get a specific cross's length

or

VolumeController.VolumeData.CrossFToDistance(pathF, crossF) to compute the distance between two different point of coordinates (pathF, crossF1) and (pathF, crossF2)

Did that help?

Many thanks.

Perfect, I will need to use both of those at different points.

Just to confirm:

If my volume was a doughnut made of 4 control points, which has a skinny cross at the start and really fat cross half way around.

A pathF value of 0 or 1 would give the smallest value, while a pathF value of 0.5 would be the highest value?

If then, I were to select the control point at 0.25 and drag it extremely far away so that the first half of the loop is a much longer distance; would a pathF value of 0.5 still return the point exactly on the middle control point or would it now be located somewhere on the path 50% of the length?

EDIT: going back to my first question, how do I get from the volumeController to the spline so I can call gettangeant on it? I thought it would be under volumedata..

Posts: 1,148

Threads: 55

Joined: Jun 2017

(03-07-2019, 12:58 AM)Mighty183 Wrote: Just to confirm:

If my volume was a doughnut made of 4 control points, which has a skinny cross at the start and really fat cross half way around.

A pathF value of 0 or 1 would give the smallest value, while a pathF value of 0.5 would be the highest value?

Yes

(03-07-2019, 12:58 AM)Mighty183 Wrote: If then, I were to select the control point at 0.25 and drag it extremely far away so that the first half of the loop is a much longer distance; would a pathF value of 0.5 still return the point exactly on the middle control point or would it now be located somewhere on the path 50% of the length?

In the contexte of CG data (i.e CGData class and its subclasses, all used in Curvy Generator), which CGVolume is part of, a pathF of 0.5 means a point at half the total distance.

This is not to be confused with TF in the context of a spline (i.e CurvySpline class), where 0.5 means the middle control point, whatever the length of the segments are. More about the spline case here:

https://curvyeditor.com/documentation/splines/start
(03-07-2019, 12:58 AM)Mighty183 Wrote: EDIT: going back to my first question, how do I get from the volumeController to the spline so I can call gettangeant on it? I thought it would be under volumedata..

You can't get a spline from a CGVolume. But the CGVolume has the needed data in it

VolumeController.VolumeData.InterpolateDirection(pathF)

To try to explain you more the difference in Curvy between a spline (CurvySpline) and a path (CGPath), the first is a set of mathematical equations defining an infinite number of points, that are sampled when needed, while a path is the result of the spline's sampling, i.e a finite set of points on that spline.

Please consider leaving a

review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.