蓝图每次编译都会重设变量值

问题描述 投票:2回答:1

使用UE 4.23.1

[基本上,我正在遵循一个非常简单的教程。我扩展了多个基类,并且在我的任何扩展中,似乎所有组件的变量(例如,物理,碰撞,静态网格等)都在每次执行完整项目编译时都重置。

例如:我使用自定义功能(TankTrack)扩展了UStaticMeshComponent。我设置了静态网格物体组件,并将“碰撞”调整为“模拟GEnerates命中事件”。坚持下去,但是当我重新编译整个游戏时,一切都会恢复到其原始状态。帮助!

注意:这会在我声明的变量(并使UPROPERTY(EditAnywhere))以及默认设置为该组件类型的变量(例如,物理,碰撞等)上发生

这里是一个名为“ Grabber”的UActorComponent的示例。如果问题出在蓝图上,那么只有.h文件才重要?

如果我更改maxPickupWeightKg,然后重新编译,则更改将不会持久。

// 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构造函数没什么花哨的:

#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;

}
.
.
.

我的FPS蓝图层次结构:

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

谢谢!

unreal-engine4 unreal-blueprint
1个回答
0
投票

我将其放置在这里,因为我遇到了同样的问题。经过许多小时的测试和研究,我在虚幻的论坛中找到了这个答案。希望对您有所帮助。

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

© www.soinside.com 2019 - 2024. All rights reserved.