Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spline object on a spline path
#11
(02-20-2020, 01:33 AM)_Aka_ Wrote: Hi,
Indeed, I am having the same issue. I will look at this very soon.

The same value of From and To and the Position ?
I really need this. When you can tell me how to fix it ?
Reply
#12
Hi,
  1. I looked in the code of the FloatRegion attribute to try to understand. Before telling you what I found, just to give you context, FloatRegion and all the DevTools folder is a third party library. I don't own that code. So like you, I just use it to make my product, as you use Curvy to make yours. So after digging in the code, I found why the FloatRegion did not work for you: it is because the FloatRegion attribute needs a property in your code to retrieve options of the regions to display. In other words, you need to write this
    Code:
    [FloatRegion(UseSlider = true, RegionOptionsPropertyName = "TestRegionOptions", Precision = 4)]
       public FloatRegion TestRegion = FloatRegion.ZeroOne;

       RegionOptions<float> TestRegionOptions
       {
           get
           {
               return RegionOptions<float>.MinMax(0, 1);
           }
       }
    As you can see, the TestRegionOptions property provides a RegionOptions. There you can make it return other options depending on your need.
    This answer removed a hurdle from your path, but in my opinion you are following the wrong path, because ...
  2. ... there is a way simple solution: use Unity's Range attribute. Check their doc for more
  3. The difference between ShapeExtrusion's Range and SplineController's Position is that they don't use the same property drawer. The latter uses RangeEx, an extension of the Range attribute, that allows for dynamic values
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#13
(02-23-2020, 12:01 AM)_Aka_ Wrote: Hi,
  1. I looked in the code of the FloatRegion attribute to try to understand. Before telling you what I found, just to give you context, FloatRegion and all the DevTools folder is a third party library. I don't own that code. So like you, I just use it to make my product, as you use Curvy to make yours. So after digging in the code, I found why the FloatRegion did not work for you: it is because the FloatRegion attribute needs a property in your code to retrieve options of the regions to display. In other words, you need to write this
    Code:
    [FloatRegion(UseSlider = true, RegionOptionsPropertyName = "TestRegionOptions", Precision = 4)]
       public FloatRegion TestRegion = FloatRegion.ZeroOne;

       RegionOptions<float> TestRegionOptions
       {
           get
           {
               return RegionOptions<float>.MinMax(0, 1);
           }
       }
    As you can see, the TestRegionOptions property provides a RegionOptions. There you can make it return other options depending on your need.
    This answer removed a hurdle from your path, but in my opinion you are following the wrong path, because ...
  2. ... there is a way simple solution: use Unity's Range attribute. Check their doc for more
  3. The difference between ShapeExtrusion's Range and SplineController's Position is that they don't use the same property drawer. The latter uses RangeEx, an extension of the Range attribute, that allows for dynamic values
So if I want start and end position of ShapeExtrusion on spline what should I do ? Same value like SplineController.
Reply
#14
I'm trying to create speed pad by Curvy on my paths.

https://gyazo.com/4046cccdb79fa5812b0823ae97bbd495
I made this generator for my speed pad.
How it looks like in the game:
https://gyazo.com/ad6b386e7789bccddd0b88ba88bb76f7

Then make prefab of that generator and add this component to it.

The code:

Code:
[ExecuteInEditMode]
public class LongSpeedPadController : MonoBehaviour
{
   [ScriptableObjectDropdown(typeof(LaneStats))] public ScriptableObjectReference lane = default;

   [SerializeField] private Transform _startPoint = default;
   [SerializeField] private Transform _endPoint = default;
   [SerializeField] private CurvySpline _spline = default;
   [MinMaxSlider(0, 1)] [SerializeField] private Vector2 _range = new Vector2(0f, 1f);
   [SerializeField] private InputSplinePath _inputSplinePath = default;
   [SerializeField] private BuildShapeExtrusion _buildShapeExtrusion = default;
   [SerializeField] private ModifierPathRelativeTranslation _modifierPathRelativeTranslation = default;

   private LaneService _laneService;
   private LanePropertiesService _lanePropertiesService;
   private LongSpeedPadProperty _longSpeedPad;

   [Inject]
   public void Constrcut(LaneService laneService, LanePropertiesService lanePropertiesService)
   {
       _laneService = laneService;
       _lanePropertiesService = lanePropertiesService;
   }

   void Start()
   {
       if (Application.isPlaying)
       {
           AddToTheList();
       }
   }

   void OnValidate()
   {
       if (_inputSplinePath != null)
       {
           _inputSplinePath.Spline = _spline;
       }
       if (_buildShapeExtrusion != null)
       {
           _buildShapeExtrusion.From = _range.x;
           _buildShapeExtrusion.To = _range.y;
       }
       if (_modifierPathRelativeTranslation != null)
       {
           _modifierPathRelativeTranslation.LateralTranslation = ((LaneStats)lane.value).offset;
       }
   }

   private void AddToTheList()
   {
       float startPoisition = _spline.TFToDistance(_spline.GetNearestPointTF(_startPoint.position));
       //float startPoisition = _spline.TFToDistance(_range.x);
       float endPoisition = _spline.TFToDistance(_spline.GetNearestPointTF(_endPoint.position));
       //float endPoisition = _spline.TFToDistance(_range.y);

       float offset = _laneService.GetOffset(lane);
       _longSpeedPad = new LongSpeedPadProperty(_laneService.GetWorldPosition(_spline, startPoisition, offset),
           _laneService.GetWorldPosition(_spline, endPoisition, offset));
       _lanePropertiesService.AddLaneProperty((Lane)_laneService.GetOffset(lane), _longSpeedPad);
   }
}

1) If I change lane, it changes ModifierPathRelativeTranslation.LateralTranslation but if I don't apply the prefab changes after playing it get back to the default prefab number. What should I do ? (Same for Range too)

2) I receive this error and I don't know why and how to fix it:
https://gyazo.com/589a459db17961db4f12240c319e0e8b
The error in line 52 of LongSpeedPadController is this line:
Code:
_buildShapeExtrusion.To = _range.y;

3) I want start and end of this speed pad but I can't get it from range because it is not same as SplineController position. What should I do ?
Reply
#15
1) I will take a look at that
2) you need to assign a non null value to _buildShapeExtrusion before it is accessed. The default keyword can have a null reference too. Read its documentation to learn more about it
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#16
1) I took a look at it, could not reproduce it. I created your scenario, and after exiting play mode my object still has the value different than the prefab's one. Send me a reproduction setup with step by step instruction, maybe then I could reproduce 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
#17
Hey _Aka_,

https://drive.google.com/file/d/1_njK1N8...sp=sharing

I made this scene for you to check it out.

1) That resetting value problem which I told you, was because of commenting Undo.DestroyObjectImmediate(gameObject); in Delete function of CGModule. It works correct now.
But another problem after solving resetting problem happens. Which is after play mode if I try to change position or lane of an object it creates another mesh besides the mesh which was created before. It happens each time you change lane or position value after first time you hit the play button.

2) Still I get that error.

3) Also I want to know why position (To and From) is different that Spline Controller position and how I can fix it ? (I really need end and start of the mesh and same as Spline Controller position)
Reply
#18
Hi,
  1. I am looking into this
  2. The documentation of OnValidate says: "This function is called when the script is loaded or a value is changed in the Inspector". So your error happens when executing OnValidate when script is loaded, because the Curvy Generator modules are not ready yet. Add this at the start of your OnValidate and it should work
    Code:
    if (isActiveAndEnabled == false)

                return;
  3. If by different you mean displayed differently, then
(02-23-2020, 12:01 AM)_Aka_ Wrote:
  1. The difference between ShapeExtrusion's Range and SplineController's Position is that they don't use the same property drawer. The latter uses RangeEx, an extension of the Range attribute, that allows for dynamic values
But if you mean that the actual value is different, then it's normal, it's two different scripts and the values have different meanings. You can synchronize them in your own script using the API if this is what you want
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#19
So, about issue number 1 : your problem is the same as in this thread. The link has an explanation of the issue and its solution. The only difference is that in your case Unity stopped the destruction quietly, without showing the error message.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#20
(02-29-2020, 11:19 PM)_Aka_ Wrote: Hi,
  1. I am looking into this
  2. The documentation of OnValidate says: "This function is called when the script is loaded or a value is changed in the Inspector". So your error happens when executing OnValidate when script is loaded, because the Curvy Generator modules are not ready yet. Add this at the start of your OnValidate and it should work
    Code:
    if (isActiveAndEnabled == false)

                return;
  3. If by different you mean displayed differently, then
(02-23-2020, 12:01 AM)_Aka_ Wrote:
  1. The difference between ShapeExtrusion's Range and SplineController's Position is that they don't use the same property drawer. The latter uses RangeEx, an extension of the Range attribute, that allows for dynamic values
But if you mean that the actual value is different, then it's normal, it's two different scripts and the values have different meanings. You can synchronize them in your own script using the API if this is what you want

Thanks for the reply.

How can I sync Shape Extrusion Range value and Spline Controller Position value by your API ? I want same values, because I want to compare player position with start and end of that speed pad.

(02-29-2020, 11:46 PM)_Aka_ Wrote: So, about issue number 1 : your problem is the same as in this thread. The link has an explanation of the issue and its solution. The only difference is that in your case Unity stopped the destruction quietly, without showing the error message.

I didn't find any solutions in that topic. That last post in that topic hides all meshes which are generated by Curvy and it doesn't work.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
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
  How could I get position in spline from "From" value in BuildRasterizedPath? Chanon 1 8 02-12-2024, 09:54 PM
Last Post: _Aka_

Forum Jump: