Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spline object on a spline path
#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


Messages In This Thread
Spline object on a spline path - by ATHellboy - 02-11-2020, 01:14 PM
RE: Spline object on a spline path - by _Aka_ - 02-14-2020, 10:47 AM
RE: Spline object on a spline path - by ATHellboy - 02-16-2020, 04:54 AM
RE: Spline object on a spline path - by _Aka_ - 02-16-2020, 08:08 PM
RE: Spline object on a spline path - by ATHellboy - 02-17-2020, 09:43 AM
RE: Spline object on a spline path - by _Aka_ - 02-17-2020, 11:56 AM
RE: Spline object on a spline path - by _Aka_ - 02-17-2020, 12:16 PM
RE: Spline object on a spline path - by ATHellboy - 02-17-2020, 12:32 PM
RE: Spline object on a spline path - by ATHellboy - 02-19-2020, 03:21 PM
RE: Spline object on a spline path - by _Aka_ - 02-20-2020, 01:33 AM
RE: Spline object on a spline path - by ATHellboy - 02-20-2020, 05:45 AM
RE: Spline object on a spline path - by _Aka_ - 02-23-2020, 12:01 AM
RE: Spline object on a spline path - by ATHellboy - 02-23-2020, 04:41 AM
RE: Spline object on a spline path - by ATHellboy - 02-23-2020, 07:19 AM
RE: Spline object on a spline path - by _Aka_ - 02-25-2020, 12:11 AM
RE: Spline object on a spline path - by _Aka_ - 02-25-2020, 12:17 AM
RE: Spline object on a spline path - by ATHellboy - 02-26-2020, 03:44 PM
RE: Spline object on a spline path - by _Aka_ - 02-29-2020, 11:19 PM
RE: Spline object on a spline path - by _Aka_ - 02-29-2020, 11:46 PM
RE: Spline object on a spline path - by ATHellboy - 03-01-2020, 09:30 AM
RE: Spline object on a spline path - by _Aka_ - 03-01-2020, 03:12 PM
RE: Spline object on a spline path - by ATHellboy - 03-01-2020, 04:37 PM
RE: Spline object on a spline path - by _Aka_ - 03-01-2020, 05:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rasterized Path Range issue proton 3 15 04-27-2024, 09:26 AM
Last Post: proton
  Incorrect mesh alignment after extrusion on curved path Thinkurvy 10 21 04-17-2024, 10:57 AM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_

Forum Jump: