# 4.7p3 Changing Closed Loop on a spline doesn't cause its length to change

**URL:** <https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196>\
**Category:** Blueprint\
**Tags:** UE4-7, unreal-engine, Spline, Blueprint, question\
**Created:** [January 17, 2015, 12:57am UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196 "2015-01-17T00:57:57Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_17ec24a01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_17ec24a01](https://forums.unrealengine.com/u/anonymous_user_17ec24a01)\
**Post date:** [January 17, 2015, 12:57am UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196/1 "2015-01-17T00:57:57Z")

</div>

If you have a spline that is not a closed loop, get its length, call set close loop to true, and get its length again, it still returns the original length. Vice versa if it started closed, its length never gets shorter if you later change it to open.

To repro:

Create a new blueprint, say spline\_test. Open it up and add two splines, first spline and second spline. Leave first spline as open loop and set second spline closed loop to true.

I made a debug function in this spline\_test BP like this:

 ![26974-spline1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/1/1/e11f55e7e1577b5dfb07ffae9563788f5fc6d1fa.jpeg)

And a function to print out a spline, its current open/closed state, and its current length. Then flip the close loop flag on the spline for next time.

 ![26975-spline2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/6/d/b6d49234d38c6e9b5ff0cedc14d77a93bf4df8b9.jpeg)

Finally a quick bit in the level map to debug this by pressing F key.

![26976-spline3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/f/c/6fcd5957899b3d875f4687c79e9004638e5fb294.jpeg)

So now you can see when it starts up, s1 is an open spline and has length of 100. s2 is a close spline with a length of 200, twice as long as you would expect. Now hit F key. You see that s1 and s2 both alternate between open and closed loops as expected, however you will see that s1 always reports its length as 100 and s2 always as 200 no matter their open/closed states.

![26977-spline4.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/5/5/e558e17d4dbab2dbd153176c319866b06a3dce38.jpeg)

---

<div class="post-metadata">

**Author:** ![TJ\_V](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tj_v/32/1008648_2.png) [@TJ\_V](https://forums.unrealengine.com/u/TJ_V)\
**Post date:** [January 19, 2015, 5:25pm UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196/2 "2015-01-19T17:25:57Z")

</div>

Hi Furroy,

Thank you for the report. I was able to reproduce this in the 4.7.0 Preview. I’m still investigating the cause but I plan to post back here with an update soon.

---

<div class="post-metadata">

**Author:** ![TJ\_V](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tj_v/32/1008648_2.png) [@TJ\_V](https://forums.unrealengine.com/u/TJ_V)\
**Post date:** [January 19, 2015, 7:28pm UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196/3 "2015-01-19T19:28:18Z")

</div>

I’m unsure of a workaround for this issue. It seems that setting a spline to a closed or open loop isn’t reflected if it is done through blueprints. I have created UE JIRA-7792 in our tracking software and our developers will be investigating the issue further.

Cheers,

TJ

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_17ec24a01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_17ec24a01](https://forums.unrealengine.com/u/anonymous_user_17ec24a01)\
**Post date:** [January 19, 2015, 7:41pm UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196/4 "2015-01-19T19:41:13Z")

</div>

If anyone gets stuck on this, my own workaround is to create them always closed and my own get length function knows to optionally subtract the last segment for open loops. But if you guys can fix it in the engine that would be ideal. Ty.

---

<div class="post-metadata">

**Author:** ![TJ\_V](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tj_v/32/1008648_2.png) [@TJ\_V](https://forums.unrealengine.com/u/TJ_V)\
**Post date:** [January 19, 2015, 7:53pm UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196/5 "2015-01-19T19:53:06Z")

</div>

Sounds good, thanks for posting your workaround.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_17ec24a01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_17ec24a01](https://forums.unrealengine.com/u/anonymous_user_17ec24a01)\
**Post date:** [January 22, 2015, 2:31am UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196/6 "2015-01-22T02:31:17Z")

</div>

Well I feel kind of silly after spending all day debugging another issue with splines, I should have guessed the root cause was related to the length bug. So I’m letting you know changing open/closed on a spline also does not update the spline point tangent of the last point as you would expect. It’s probably the same bug, but they’ll want to test for both cases.

Here I am expecting for the last tangent to change from \<0, 0, 0\> that it should be for a closed loop to \<1, 0, 0\> which is normal for an open loop. But it still reports \<0, 0, 0\> after opening the loop.

 ![27514-closed_spline.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/4/d/a4d459d5fa7570259286c8dbb86cf3512c068430.jpeg)

---

<div class="post-metadata">

**Author:** ![TJ\_V](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tj_v/32/1008648_2.png) [@TJ\_V](https://forums.unrealengine.com/u/TJ_V)\
**Post date:** [January 22, 2015, 2:52pm UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196/7 "2015-01-22T14:52:50Z")

</div>

Hi Furroy,

I believe you are correct, this seems directly related to the open/close length issue. I will update the report so the devs will know.

Thanks again,

TJ

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a927dd6e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a927dd6e](https://forums.unrealengine.com/u/anonymous_user_a927dd6e)\
**Post date:** [January 22, 2015, 3:13pm UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196/8 "2015-01-22T15:13:49Z")

</div>

I have a fix for this which is currently in internal review and will be submitted soon. The problem is, as you suspected, that the Blueprint function to set the closed loop state wasn’t updating the spline afterwards.

I’ll report back here when there’s a changelist you can integrate. Meanwhile, if you want a rough and ready fix, you can add the following line into USplineComponent::SetClosedLoop:

```
void USplineComponent::SetClosedLoop(bool bInClosedLoop)
{
	if (bClosedLoop != bInClosedLoop)
	{
		bClosedLoop = bInClosedLoop;

		if (bClosedLoop)
		{
			AddLoopEndpoint();
		}
		else
		{
			RemoveLoopEndpoint();
		}

        UpdateSpline(); // <<<<< ADD THIS LINE
	}
}

```

It’s not especially optimal, but there’ll be some spline component optimizations coming in the near future which should improve performance.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_21a58d97](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_21a58d97](https://forums.unrealengine.com/u/anonymous_user_21a58d97)\
**Post date:** [September 4, 2015, 6:40pm UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196/9 "2015-09-04T18:40:10Z")

</div>

Hello,

has this been fixed?

Thank you.

---

<div class="post-metadata">

**Author:** ![TJ\_V](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tj_v/32/1008648_2.png) [@TJ\_V](https://forums.unrealengine.com/u/TJ_V)\
**Post date:** [September 8, 2015, 4:19pm UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196/10 "2015-09-08T16:19:26Z")

</div>

Hi ,

This was fixed in the 4.8 release. Are you seeing it in that build or 4.9?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_af553a2a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_af553a2a](https://forums.unrealengine.com/u/anonymous_user_af553a2a)\
**Post date:** [July 5, 2016, 9:58am UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196/11 "2016-07-05T09:58:03Z")

</div>

Has this been fixed? Because in 4.11.2 if i use “Get Location at Distance along Spline” with the length i get from “Get Spline Length” i end up at the last Point of the Spline not the first as it should be with a closed Spline IMO. This is bad if you want to use a Spline as for example a Raceline or something like that.

Edit: It does not work if i set the Spline to be closed in the editor. Seems to work if i use “Set Closed Loop” in the construction script of the Actor containing the Spline.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a927dd6e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a927dd6e](https://forums.unrealengine.com/u/anonymous_user_a927dd6e)\
**Post date:** [July 8, 2016, 3:29pm UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196/12 "2016-07-08T15:29:37Z")

</div>

Hi avision,

Thanks for the bug report - am I right to believe that this problem only shows up when trying to Get Spline Length in a Construction Script? There was a problem with the propagation of the bClosedLoop property, which is now fixed, and should be in the upcoming 4.13 release.

---

<div class="post-metadata">

**Author:** ![Nameless\_Voice](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nameless_voice/32/747563_2.png) [@Nameless\_Voice](https://forums.unrealengine.com/u/Nameless_Voice)\
**Post date:** [December 9, 2020, 1:03am UTC](https://forums.unrealengine.com/t/4-7p3-changing-closed-loop-on-a-spline-doesnt-cause-its-length-to-change/304196/13 "2020-12-09T01:03:39Z")

</div>

Many years later, but there’s still a related bug to this one even in 4.26.

If you adjust the “Closed Loop” option on the spline component of an actor in the world, then the change will not be visible in the construction script - it will continue to see the old length and the closed loop property in its old state.

However, if you change the option on the blueprint class that the actor is derived from, then that change will be propagated to the world object.

This is probably related to [Unreal Engine Issues and Bug Tracker (UE-36728)](https://issues.unrealengine.com/issue/UE-36728) - though the bug is larger than just that one property not being read.
