Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Feature request: SplineController.Position as inspector property
#3
(01-17-2018, 11:11 PM)_Aka_ Wrote: I will try to make this work in the coming week. I will let you know here about the result of my attempt.

Thanks. Let me know if you need a beta tester.

I have this working with an external script that simply exposes the needed parameter as a simple public float, initializes the float from the SplineController's own Position value at Start() time, then copies its own value to the SplineController's Position during Update(), LateUpdate(), or FixedUpdate() depending on which mode is selected.

For what it's worth, and in case it's helpful to anyone else, here's my working script, tested in Unity 2017.3.0f3 with Timeline.

Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FluffyUnderware.Curvy.Controllers;

/*
* Exposes the Position value of a Curvy SplineController as a write-only property
* in the Unity inspector, to allow it to be animated with Timeline.
* This implementation assumes Relative position and move mode becasue that allows
* the inspector to set a range and provide a slider for the value, which is
* useful in visualizing the animation while editing Timeline. Experimentation
* also suggests Relative mode is better for Timeline animations because you
* don't have to later update the Timeline curves or keyframe values if the
* Curvy spline's length is changed.
*
* This is proof-of-concept code, not intended for production use.
*
* Author: Scott Courtney ("Syscrusher")
* License: MIT License
*/

[RequireComponent(typeof(SplineController))]
public class CurvySplineControllerPosition : MonoBehaviour {

SplineController curvy;

[Range(0.0f, 1.0f)]
public float RelativePosition;

// Initialize and set the prerequisites on the SplineController.
void Start () {
curvy = GetComponent<SplineController>();
curvy.PositionMode = FluffyUnderware.Curvy.CurvyPositionMode.Relative;
curvy.MoveMode = FluffyUnderware.Curvy.CurvyController.MoveModeEnum.Relative;
RelativePosition = curvy.Position;
curvy.Play();
}

// Push our position setting to the SplineController object
void PushPosition() {
if (isActiveAndEnabled) {
curvy.Position = RelativePosition;
}
}

// Update is called once per frame
void Update () {
if (curvy.UpdateIn == FluffyUnderware.Curvy.CurvyUpdateMethod.Update) {
PushPosition();
}
}

void FixedUpdate() {
if (curvy.UpdateIn == FluffyUnderware.Curvy.CurvyUpdateMethod.FixedUpdate) {
PushPosition();
}
}

void LateUpdate() {
if (curvy.UpdateIn == FluffyUnderware.Curvy.CurvyUpdateMethod.LateUpdate) {
PushPosition();
}
}
}
Reply


Messages In This Thread
RE: Feature request: SplineController.Position as inspector property - by syscrusher - 01-18-2018, 12:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Play() does not cause SplineController to produce expected behaviour ConCat 8 1,359 02-08-2026, 11:54 AM
Last Post: _Aka_
  SplineController Ignores Follow-Up and Chooses Wrong Spline Josenildo 7 4,462 07-29-2025, 09:15 PM
Last Post: _Aka_
  Is there a way to get the position of each ControlPoint in spline by API? Chanon 1 2,130 06-07-2025, 09:44 AM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 1,777 03-28-2024, 10:08 PM
Last Post: _Aka_

Forum Jump: