Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't delete connection
#1
Thumbs Up 
I have a gameobject following two connected splines. Splines are connected at runtime. When the object is destroyed I want to disconnect the splines. I have the following code;

Code:
            
pooledObject.SplineController.Stop();
if (pooledObject.SplineConnection != null)
{
     ObjectExt.Destroy(pooledObject.SplineConnection, false, false);
}

When the code is called I get the following error;

Destroying components immediately is not permitted during physics trigger/contact, animation event callbacks, rendering callbacks or OnValidate. You must use Destroy instead.
UnityEngine.ObjectBig GrinestroyImmediate (UnityEngine.Object)

What checks do I need to do to make sure I can delete the connection?

Thanks
Reply
#2
Hi
To avoid this issue, I suggest to follow another path, which is disconnecting the splines without destroying the connection. This way th connection game object will remain, but it will not connect the two splines.
To do so, iterate through the control points in yourConnection.ControlPointsList, and for each one of them call the yourControlPoint.Disconnect(false) method.
Please let me know if this worked out.
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
That works! I created a connection pool and recycle the connections as needed, disconnecting them when I return them to the pool. Thanks
Reply
#4
Glad to read that.
If and when you feel like it, please leave a review for the asset, that helps a lot.
Have a nice day.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
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_
Lightbulb Junction & Connection Navigation System Design SAMYTHEBIGJUICY 4 13 11-27-2023, 01:04 PM
Last Post: _Aka_
  Connection "next' control point jh092 3 15 11-22-2023, 11:47 AM
Last Post: _Aka_
  insecure connection refused schema 1 2 05-03-2023, 12:30 PM
Last Post: _Aka_

Forum Jump: