首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Blueprints在每次编译时重置变量值

Blueprints在每次编译时重置变量值
EN

Stack Overflow用户
提问于 2019-12-11 02:20:47
回答 2查看 1.7K关注 0票数 2

使用UE 4.23.1

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

例如:我使用自定义功能(TankTrack)扩展了UStaticMeshComponent。我设置了静态网格组件,并将碰撞调整为“模拟GEnerates命中事件”。这一点仍然有效,但是一旦我重新编译了整个游戏,所有东西都会恢复到原来的状态。救命!!

注意:这会发生在我声明的变量(并使UPROPERTY(EditAnywhere))以及那些默认为该组件类型的变量(例如,物理、冲突等)上。

下面是一个包含名为"Grabber“的UActorComponent的示例。如果蓝图有问题,只有.h文件才重要?

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

代码语言:javascript
复制
// 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构造函数并不花哨:

代码语言:javascript
复制
#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蓝图的层次结构如下:

代码语言:javascript
复制
FirstPersonCharacter(self)
-
CapsuleComponent (This is where all the player meshes are)
-
CharacterMovement
PhysicsHandle
Grabber

谢谢!

EN

回答 2

Stack Overflow用户

发布于 2020-08-21 20:41:17

在使用4.25.3时,这个问题仍然没有得到解决。我的解决方法是创建组件的子蓝图,并在我的Actor上使用它。这样,在编译时不会重置属性值。

票数 1
EN

Stack Overflow用户

发布于 2020-04-14 03:41:08

我把这个放在这里是因为我也遇到过同样的问题。经过长时间的测试和研究,我在虚幻的论坛上找到了这个答案。我希望它能帮上忙。

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59273247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档