This is still the first thing that comes up when you Google this issue. I’ll leave this answer here for anyone else stumbling across it. Turns out it’s really easy to set the cable up to simulate locally. The required code is already in UCableComponent, it’s just not used.
Create a child C++ class from UCableComponent called ULocalCableComponent, and have this as .h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CableComponent.h"
#include "LocalCableComponent.generated.h"
/**
*
*/
UCLASS(hidecategories = (Object, Physics, Activation, "Components|Activation"), editinlinenew, meta = (BlueprintSpawnableComponent), ClassGroup = Rendering)
class YOURPROJECTNAME_API ULocalCableComponent : public UCableComponent
{
GENERATED_BODY()
public:
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
protected:
FVector _previousWorldLocation;
};
and .cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "LocalCableComponent.h"
void ULocalCableComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
if(!_previousWorldLocation.IsZero())
{
ApplyWorldOffset(GetComponentLocation() - _previousWorldLocation, false);
}
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
_previousWorldLocation = GetComponentLocation();
};
I’ve also written a quick blog post about it if you’d like some more guidance: Simulating cable components in local space.