【发布时间】:2020-04-03 23:52:48
【问题描述】:
使用 UE 4.23.1
基本上,我正在学习一个非常简单的教程。 我扩展了多个基类,似乎在我的任何扩展中,所有组件(例如,物理、碰撞、静态网格等)的变量都在每次我进行完整的项目编译时都会重置。
例如: 我用自定义功能(TankTrack)扩展了 UStaticMeshComponent。我设置了静态网格组件,并将碰撞调整为“模拟生成命中事件”。这坚持,但只要我重新编译整个游戏,一切都恢复到原来的状态。救命!!
注意:这发生在我声明的变量(并使 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
谢谢!
【问题讨论】:
-
您最好在 udn 上询问更多的狭窄再现(如果您终止虚幻进程是否会发生,如果您将所有内容保存在编辑器中是否会发生等等......)。除此之外,您应该确保所有未默认构造和初始化的变量都在您的 tanktrack 中初始化,并且所有继承的函数都正确路由。
-
仅供参考,如果您修正标点符号和格式以便更易于阅读,将会有更多人认真查看您的问题。 stackoverflow.com/help/how-to-ask
-
能否也包括相关代码。在这种情况下,.cpp 文件中的类的 .h 和构造函数。
-
已更新代码 -- 确认 4.23 和 4.24 都会发生这种情况。
-
看来我想通了。正在为整个项目使用“编译”按钮来保存所有内容,而无需点击“保存当前”。我猜 UE 只需要混搭 Save Current!
标签: unreal-engine4 unreal-blueprint