Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NullReferenceException when enable and disable curves with followups
#1
Hey, i have the problem that when i enable and disable parts of my level it always throws Null Ref Errors. This happens when i disable segments behind the player and enable other segments in fron of the player. 

Code:
NullReferenceException: Object reference not set to an instance of an object
FluffyUnderware.Curvy.CurvySplineSegment.CanFollowUpHeadToEnd (FluffyUnderware.Curvy.CurvySplineSegment followUp) (at Assets/Plugins/ToolBuddy/Assets/Curvy/Scripts/Splines/CurvySplineSegment.cs:2079)
FluffyUnderware.Curvy.ConnectionHeadingEnumMethods.ResolveAuto (FluffyUnderware.Curvy.ConnectionHeadingEnum heading, FluffyUnderware.Curvy.CurvySplineSegment followUp) (at Assets/Plugins/ToolBuddy/Assets/Curvy/Scripts/Splines/Connections/ConnectionHeadingEnumMethods.cs:25)
FluffyUnderware.Curvy.CurvySpline.GetFollowUpHeadingControlPoint (FluffyUnderware.Curvy.CurvySplineSegment followUp, FluffyUnderware.Curvy.ConnectionHeadingEnum headingDirection) (at Assets/Plugins/ToolBuddy/Assets/Curvy/Scripts/Splines/CurvySpline.cs:879)
FluffyUnderware.Curvy.CurvySplineSegment+ThreadSafeData.Set (System.Boolean useFollowUp, FluffyUnderware.Curvy.CurvySplineSegment curvySplineSegment, FluffyUnderware.Curvy.CurvySplineSegment& nextCP) (at Assets/Plugins/ToolBuddy/Assets/Curvy/Scripts/Splines/CurvySplineSegment.ThreadSafeData.cs:75)
FluffyUnderware.Curvy.CurvySplineSegment.PrepareThreadCompatibleDataINTERNAL (System.Boolean useFollowUp) (at Assets/Plugins/ToolBuddy/Assets/Curvy/Scripts/Splines/CurvySplineSegment_private.cs:682)
FluffyUnderware.Curvy.CurvySpline.PrepareThreadCompatibleData () (at Assets/Plugins/ToolBuddy/Assets/Curvy/Scripts/Splines/CurvySpline_private.cs:1024)
FluffyUnderware.Curvy.CurvySpline+DirtinessManager.ProcessDirtyControlPoints () (at Assets/Plugins/ToolBuddy/Assets/Curvy/Scripts/Splines/CurvySpline.DirtinessManager.cs:293)
UnityEngine.Debug:LogException(Exception, Object)
FluffyUnderware.DevTools.DTLog:LogException(Exception, Object) (at /Users/daniel/Repositories/VR_Sugarhill/Assets/Plugins/ToolBuddy/Dependencies/DevTools/Classes/DTUtility.cs:936)
FluffyUnderware.Curvy.DirtinessManager:ProcessDirtyControlPoints() (at Assets/Plugins/ToolBuddy/Assets/Curvy/Scripts/Splines/CurvySpline.DirtinessManager.cs:306)
FluffyUnderware.Curvy.CurvySpline:Initialize() (at Assets/Plugins/ToolBuddy/Assets/Curvy/Scripts/Splines/CurvySpline_private.cs:637)
FluffyUnderware.Curvy.CurvySpline:OnEnable() (at Assets/Plugins/ToolBuddy/Assets/Curvy/Scripts/Splines/CurvySpline_private.cs:431)
UnityEngine.GameObject:SetActive(Boolean)
LevelController:SetSectionVisibility(LevelSection, Boolean) (at Assets/05_Scripts/LevelController.cs:287)
LevelController:Update() (at Assets/05_Scripts/LevelController.cs:258)
Reply
#2
Hi Phaix,
Sorry for this issue, and thanks for reporting it. I will get back to you with an answer in the upcoming days.
Have a nice day
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply
#3
Thanks, hope you get it fixed.
Reply
#4
Hi again,
Disabling segments of a spline is not supported. A spline has either to be fully enabled or fully disabled. If you want to switch between two versions of a spline, duplicate the spline, remove the segments in the second spline, and then switch the spline controller between the two splines.
Did this help?
Have a nice day.
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply
#5
Thanks, but I am building the level procedural out of pre build track prefabs and connect the spline Segments on the fly. I then deactivated these parts until the player gets near to save performance. Old parts behind the player gets deactivated for the same reason.

Maybe you have a different Approach how i could connect predefined spline Segments?
Reply
#6
The way I would do it:
Have 2 splines. One you author at edit time, this is the spline of your level. Let's call it A. The other is empty, and will be filled at runtime. Let's call it be.
At runtime, your generator should use spline B. Spline B should be filled dynamically with the relevant control points from spline A, meaning CPs that are neighboring your player's position.
With this solution, you don't enable disable CPs from A, but add/remove CPs from B.

Example scene 51_InfiniteTrack does something that might help you. It generated an infinite track it by alternating between multiple generators, each with its own spline. The spline of each generator is updated dynamically.
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply
#7
Thanks, will take a look into it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Disable a spline's gizmo when not selected or disabled. mikechr2000 1 1,701 02-03-2025, 09:34 AM
Last Post: _Aka_
  Disable rebuild of meshes in dynamic mode Zilk1 3 2,135 05-27-2024, 08:14 AM
Last Post: _Aka_
Heart Create beautiful curves ShiroeYamamoto 3 2,609 03-26-2024, 06:25 PM
Last Post: _Aka_
  Disable Generator Rasterized Objects SAMYTHEBIGJUICY 3 2,351 09-01-2023, 03:38 PM
Last Post: _Aka_

Forum Jump: