Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spline Controller Flickering
#4
Ok so I was able to recreate it - you can attach this script to an empty game object.

If you look at line 44 "Spline.Add(new Vector3(0, 0, 30 - Spline.Length));" I'm attempting to use the current length of the spline to ensure the length is always 30.

If you change line 44 from 
Code:
Spline.Add(new Vector3(0, 0, 30 - Spline.Length));
to
Code:
Spline.Add(new Vector3(0, 0, 30));

The issue goes away.

Any help much appreciated!



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

public class SplineTest : MonoBehaviour
{
    // Start is called before the first frame update
    private CurvySpline Spline;
    private List<SplineFollower> Followers = new List<SplineFollower>();
    void Start()
    {
        Spline = gameObject.AddComponent(typeof(CurvySpline)) as CurvySpline;

        // Create Spline Followers\Controllers
        for (int i = 0; i < 6; i++)
        {
            Followers.Add(new SplineFollower(Spline,i * 5));
        }

        Spline.Add(new Vector3(0, 0, 0));
        Spline.Add(new Vector3(0, 0, 30));
    }

    // Update is called once per frame
    void Update()
    {
        Spline.Clear();
        Spline.Add(new Vector3(0, 0, 0));
        // Create first Control point
        Spline.Add(new Vector3(0, 0, 0));

        //Create random number of control points
        int rnd = Random.Range(1, 5);
        for (int i = 1; i < rnd; i++)
        {
            Spline.Add(new Vector3(0, 0, i * 4));
        }

        Debug.LogWarning($"SplineLength: {Spline.Length} LastCPZ: {Spline.LastSegment.transform.position.z}");

        // Create last Control point
        Spline.Add(new Vector3(0, 0, 30 - Spline.Length));

       

        foreach (var item in Followers)
        {
            item.Move(0.1f);
        }
    }

    public class SplineFollower
    {
        public SplineController Controller;
        public float Position;

        public SplineFollower(CurvySpline spline, float position)
        {
            GameObject go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            Controller = go.AddComponent(typeof(SplineController)) as SplineController;
            Controller.PositionMode = CurvyPositionMode.WorldUnits;
            Controller.Spline = spline;
            Position = position;
        }

        public void Move(float amount)
        {
            Position += amount;
            Controller.Position = Position;
        }
    }
}
Reply


Messages In This Thread
Spline Controller Flickering - by blabz2007 - 08-27-2021, 11:38 PM
RE: Spline Controller Flickering - by _Aka_ - 08-28-2021, 08:55 AM
RE: Spline Controller Flickering - by blabz2007 - 08-31-2021, 12:15 AM
RE: Spline Controller Flickering - by blabz2007 - 08-31-2021, 07:31 PM
RE: Spline Controller Flickering - by _Aka_ - 08-31-2021, 08:56 PM
RE: Spline Controller Flickering - by blabz2007 - 09-02-2021, 11:03 PM
RE: Spline Controller Flickering - by _Aka_ - 09-03-2021, 09:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Set Volume to the Volume Controller at Runtime pako88 2 10 04-08-2024, 03:26 PM
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_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_

Forum Jump: