使用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谢谢!
发布于 2020-08-21 20:41:17
在使用4.25.3时,这个问题仍然没有得到解决。我的解决方法是创建组件的子蓝图,并在我的Actor上使用它。这样,在编译时不会重置属性值。
发布于 2020-04-14 03:41:08
我把这个放在这里是因为我也遇到过同样的问题。经过长时间的测试和研究,我在虚幻的论坛上找到了这个答案。我希望它能帮上忙。
https://stackoverflow.com/questions/59273247
复制相似问题