I’ve been stuck in this lesson for a while, saw that even if I followed what the video says (changing the wall properties to movable, changing the moveOffSet of -600 and etc…), my wall instead of moving down starts stuttering up and down. I found a similar problem on the Udemy’s questions, but it didn’t fix the problem for me, here my code for the mover:
Mover.cpp:
#include "Mover.h"
#include "Math/UnrealMathUtility.h"
UMover::UMover()
{
PrimaryComponentTick.bCanEverTick = true;
}
void UMover::BeginPlay()
{
Super::BeginPlay();
originalLocation = GetOwner()->GetActorLocation();
}
void UMover::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
FVector currentLocation = GetOwner()->GetActorLocation();
FVector targetLocation = originalLocation + moveOffSet;
float speed = FVector::Distance(currentLocation, targetLocation) / moveTime;
FVector newLocation = FMath::VInterpConstantTo(originalLocation, targetLocation, DeltaTime, speed);
GetOwner()->SetActorLocation(newLocation);
}
Mover.h:
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Mover.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class CRYPTRAIDER_API UMover : public UActorComponent
{
GENERATED_BODY()
public:
UMover();
protected:
virtual void BeginPlay() override;
public:
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
private:
UPROPERTY(EditAnywhere)
FVector moveOffSet;
UPROPERTY(EditAnywhere)
float moveTime = 4;
UPROPERTY(EditAnywhere)
bool shouldMove = false;
FVector originalLocation;
};
I’m in version 5.3, I also tried to see if it was a collision thing, but the same problem happens if I put the wall in the sky far away from other objects (I’m using the SM_Dungeon_Wall_Decorative_D probably doesn’t matter, because the same problem happens with any other object).
Anyway thank for the help in advance!