# UE4 16.3 Potential bug in CableComponent.CPP and solution

**URL:** <https://forums.unrealengine.com/t/ue4-16-3-potential-bug-in-cablecomponent-cpp-and-solution/432094>\
**Category:** C++\
**Tags:** cable-component, unreal-engine, bug-report, CPP, question\
**Created:** [August 21, 2018, 7:37am UTC](https://forums.unrealengine.com/t/ue4-16-3-potential-bug-in-cablecomponent-cpp-and-solution/432094 "2018-08-21T07:37:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rit](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rit](https://forums.unrealengine.com/u/rit)\
**Post date:** [August 21, 2018, 7:37am UTC](https://forums.unrealengine.com/t/ue4-16-3-potential-bug-in-cablecomponent-cpp-and-solution/432094/1 "2018-08-21T07:37:23Z")

</div>

Bug Symptom:

When a cable attached to 2 actors with both ends, and both 2 actors move long distance by setting location, the cable component will sometimes disappear. (This bug seems to occur more often when a cable has more segments, ex: segments \> 12)

Bug Cause: When this bug occurs, printing out the location of each particle of that cable, I get this:

LogGamePlay: C++ CABLE\_DEBUG\_TEST() particle index: 0 x: -284895.406250 y: 120371.539063 z: 111.272942

LogGamePlay: C++ CABLE\_DEBUG\_TEST() particle index: 1 x: -nan(ind) y: -nan(ind) z: -nan(ind)

LogGamePlay: C++ CABLE\_DEBUG\_TEST() particle index: 2 x: -nan(ind) y: -nan(ind) z: -nan(ind)

LogGamePlay: C++ CABLE\_DEBUG\_TEST() particle index: 3 x: -nan(ind) y: -nan(ind) z: -nan(ind)

LogGamePlay: C++ CABLE\_DEBUG\_TEST() particle index: 4 x: -nan(ind) y: -nan(ind) z: -nan(ind)

LogGamePlay: C++ CABLE\_DEBUG\_TEST() particle index: 5 x: -nan(ind) y: -nan(ind) z: -nan(ind)

LogGamePlay: C++ CABLE\_DEBUG\_TEST() particle index: 6 x: -nan(ind) y: -nan(ind) z: -nan(ind)

LogGamePlay: C++ CABLE\_DEBUG\_TEST() particle index: 7 x: -nan(ind) y: -nan(ind) z: -nan(ind)

LogGamePlay: C++ CABLE\_DEBUG\_TEST() particle index: 8 x: -nan(ind) y: -nan(ind) z: -nan(ind)

LogGamePlay: C++ CABLE\_DEBUG\_TEST() particle index: 9 x: -nan(ind) y: -nan(ind) z: -nan(ind)

LogGamePlay: C++ CABLE\_DEBUG\_TEST() particle index: 10 x: -nan(ind) y: -nan(ind) z: -nan(ind)

LogGamePlay: C++ CABLE\_DEBUG\_TEST() particle index: 11 x: -nan(ind) y: -nan(ind) z: -nan(ind)

LogGamePlay: C++ CABLE\_DEBUG\_TEST() particle index: 12 x: -283573.937500 y: 120196.406250 z: 266.018738

Except for the start and end of the cable, all the particle positions are all undefined. Which leads me to suspect  
a potential bug in this function:

static void SolveDistanceConstraint(FCableParticle& ParticleA, FCableParticle& ParticleB, float DesiredDistance)

```
	// Find current vector between particles
	FVector Delta = ParticleB.Position - ParticleA.Position;
	// 
	float CurrentDistance = Delta.Size();
	float ErrorFactor = (CurrentDistance - DesiredDistance)/CurrentDistance;

```

If for some reason ParticleB.Position = ParticleA.Position, then ErrorFactor will be undefined, and cause all the particles to have invalid values, except for !bFree particles (the end points of the cable)

Bug solution:

I simply add a small number to the CurrentDistance variable before dividing it:

```
	// MYW modify bgn
	//float CurrentDistance = Delta.Size();
	float CurrentDistance = Delta.Size() + 0.01f;
	// MYW modify end

```

This is only my suspicion, I will be glad if an Epic staff can comment on this problem and solution.

Thank you!

---

<div class="post-metadata">

**Author:** ![craig-lofi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@craig-lofi](https://forums.unrealengine.com/u/craig-lofi)\
**Post date:** [January 27, 2021, 11:39am UTC](https://forums.unrealengine.com/t/ue4-16-3-potential-bug-in-cablecomponent-cpp-and-solution/432094/2 "2021-01-27T11:39:25Z")

</div>

For anyone else finding this, yes this is still an issue in 2021.

---

<div class="post-metadata">

**Author:** ![rit](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rit](https://forums.unrealengine.com/u/rit)\
**Post date:** [January 27, 2021, 12:51pm UTC](https://forums.unrealengine.com/t/ue4-16-3-potential-bug-in-cablecomponent-cpp-and-solution/432094/3 "2021-01-27T12:51:34Z")

</div>

Do you mean you still experience cable disappearing in later versions of UE4? (ex: UE4.2x ??)

Since no one reply to my original post for a long time, I always thought I am the only one who encounters this bug.

---

<div class="post-metadata">

**Author:** ![craig-lofi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@craig-lofi](https://forums.unrealengine.com/u/craig-lofi)\
**Post date:** [January 27, 2021, 1:17pm UTC](https://forums.unrealengine.com/t/ue4-16-3-potential-bug-in-cablecomponent-cpp-and-solution/432094/4 "2021-01-27T13:17:47Z")

</div>

Yup, for me the cable never seems to appear in the first place. Using version 4.25.4

If I manage to find a fix I’ll be sure to post it here

---

<div class="post-metadata">

**Author:** ![rit](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rit](https://forums.unrealengine.com/u/rit)\
**Post date:** [January 28, 2021, 10:14am UTC](https://forums.unrealengine.com/t/ue4-16-3-potential-bug-in-cablecomponent-cpp-and-solution/432094/5 "2021-01-28T10:14:49Z")

</div>

thanks in advance!! 😛

---

<div class="post-metadata">

**Author:** ![craig-lofi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@craig-lofi](https://forums.unrealengine.com/u/craig-lofi)\
**Post date:** [February 5, 2021, 6:09pm UTC](https://forums.unrealengine.com/t/ue4-16-3-potential-bug-in-cablecomponent-cpp-and-solution/432094/6 "2021-02-05T18:09:10Z")

</div>

Asked about this on UDN, got this response;  
“Thanks for reporting this. A fix has been submitted and should be available in the next release.”

---

<div class="post-metadata">

**Author:** ![rit](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rit](https://forums.unrealengine.com/u/rit)\
**Post date:** [February 5, 2021, 6:26pm UTC](https://forums.unrealengine.com/t/ue4-16-3-potential-bug-in-cablecomponent-cpp-and-solution/432094/7 "2021-02-05T18:26:47Z")

</div>

Hey!  
Thank you for taking the action to notify Epic of this bug! 😃
