3

Using UE 4.23.1

Basically, i'm following a very simple tutorial. I've extended multiple base classes, and it seems in ANY of my extensions, the variables for all components (e.g., physics, collision, static mesh, etc) all reset EVERY TIME i do a full project compile.

For instance: I've extended UStaticMeshComponent with custom functionality (TankTrack). I set the static mesh component, and adjust the Collision to "Simulation GEnerates Hit Events". This sticks, but as soon as i recompile the entire game, EVERYTHING is reverted to its original state. Help!!

Note: This happens on variables I declare (and make UPROPERTY(EditAnywhere)) as well as those defaulted to that component type (e.g., Physics, collision, etc)

Here is an example with a UActorComponent called "Grabber". Only the .h file should matter if the issue is with blueprint?

If i change maxPickupWeightKg, then recompile, the change does NOT persist.

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "PhysicsEngine/PhysicsHandleComponent.h"
#include "Grabber.generated.h"


UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class FPSExample_API UGrabber : public UActorComponent
{
    GENERATED_BODY()

public: 
    // Sets default values for this component's properties
    UGrabber();

protected:
    // Called when the game starts
    virtual void BeginPlay() override;

public: 
    // Called every frame
    virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

    /// Grabber functions and variables
    UPROPERTY(EditAnywhere, Category = "Grab Setup")
        float maxPickupWeightKg = 50.f; 

};

.cpp Constructor is nothing fancy:

#include "Grabber.h"
#include "Math/UnrealMathUtility.h"
#include "CollisionQueryParams.h"
#include "Engine/EngineTypes.h"
#include "Engine/World.h"
#include "Components/ActorComponent.h"
#include "Components/PrimitiveComponent.h"
#include "GameFramework/Actor.h"

#define OUT

// Sets default values for this component's properties
UGrabber::UGrabber()
{
    PrimaryComponentTick.bCanEverTick = true;

}
.
.
.

My Hierarchy for the FPS Blueprint this is on:

FirstPersonCharacter(self)
-
CapsuleComponent (This is where all the player meshes are)
-
CharacterMovement
PhysicsHandle
Grabber

Thanks !

stackdev
  • 83
  • 2
  • 8
  • You might be best asking on udn with a bit more of a narrow repro ( does it occur if you kill the unreal process, does it occur if you save all in the editor etc... ). Beyond that you should make sure all your variables that don't default construct and initialize are initialized in your tanktrack and that all inherited functions are correctly routed. – George Dec 10 '19 at 18:51
  • FYI, you'll get more people seriously looking at your question if you fix your punctuation and formatting so it's easier to read. https://stackoverflow.com/help/how-to-ask – Doug Richardson Dec 10 '19 at 23:13
  • Could you also include the relevant code. In this case, the .h and constructor of the class in the .cpp file. – Doug Richardson Dec 10 '19 at 23:14
  • Updated with code -- Confirmed this happens with both 4.23 and 4.24. – stackdev Dec 11 '19 at 10:17
  • Seems i figured it out. Was taking the "compile" button for the entire project to persist everything, without hitting "Save Current". I guess UE just needs to mash Save Current! – stackdev Dec 11 '19 at 17:47

2 Answers2

1

I am placing this here because I've had the same issue. After many hours of testing and research, I found this answer in the unreal forums. I hope it helps.

https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1530690-uproperty-value-keeps-resetting-on-every-compile?p=1651757#post1651757

Liam9905
  • 331
  • 3
  • 3
1

Using 4.25.3 this has still not been fixed. My workaround is to create a child blueprint of the component and use that on my Actor. This way the property values do not get reset when compiling.

Zcience
  • 11
  • 1