Added new variable in c++ to DamageType.h but it does not appear in blueprint editor?

I am attempting to add a default variable to the DamageType class in c++. I have opened DamageType.h file in VS and added a single new variable declaration (bInterruptsActions), see code below:

// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "UObject/Object.h"
#include "DamageType.generated.h"

/**
 * A DamageType is intended to define and describe a particular form of damage and to provide an avenue 
 * for customizing responses to damage from various sources.
 *
 * For example, a game could make a DamageType_Fire set it up to ignite the damaged actor.
 *
 * DamageTypes are never instanced and should be treated as immutable data holders with static code
 * functionality.  They should never be stateful.
 */
UCLASS(MinimalAPI, const, Blueprintable, BlueprintType)
class UDamageType : public UObject
{
	GENERATED_UCLASS_BODY()

	/** True if this damagetype is caused by the world (falling off level, into lava, etc). */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=DamageType)
	uint32 bCausedByWorld:1;

	/** True to scale imparted momentum by the receiving pawn's mass for pawns using character movement */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=DamageType)
	uint32 bScaleMomentumByMass:1;

	/** When applying radial impulses, whether to treat as impulse or velocity change. */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = RigidBody)
	uint32 bRadialDamageVelChange : 1;

	/** New default variable i'd like to add!!! */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = DamageType)
	bool bInterruptsActions;

	/** The magnitude of impulse to apply to the Actors damaged by this type. */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=RigidBody)
	float DamageImpulse;

	/** How large the impulse should be applied to destructible meshes */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Destruction)
	float DestructibleImpulse;

	/** How much the damage spreads on a destructible mesh */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Destruction)
	float DestructibleDamageSpreadScale;

	/** Damage fall-off for radius damage (exponent).  Default 1.0=linear, 2.0=square of distance, etc. */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=DamageType)
	float DamageFalloff;

};

but after building and reopening the editor, I do not see this new variable reflected where I would expect?

I have deleted intermediates, regenereted visual studio files, rebuilt, clean built the project, to no avail.

Any help is greatly appreciated!

Try changing to uint32 bInterruptsActions:1;
or 0 if its false.

1 Like

I should have noted, that is what I started with and it was not working either:

/** New default variable i'd like to add!!! */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = DamageType)
	uint32 bInterruptsActions:1;

Try changing the name of “bCausedByWorld”, see if it changes in blueprint.

1 Like

ok good recommend! changed the name of “bCausedByWorld” to “btestingnamechange”…

I built in VS and ran editor: the variable name did NOT change in the blueprint editor. So these variables either must be getting set elsewhere? Or am I not compiling/building/updating the code correctly?

What code are you rebuilding?

If this is a core Unreal Engine class, you will need to re-generate and re-build both the editor, and the support code for packaged games, and then make sure you start the new editor you built, not the one from the Epic Launcher.

It might be better to create a DamageType subclass that has the new fields you want, which can be done in a C++ plugin in the regular editor.
You would then make all your damage types you actually use derive from YourDamageType, and when you get a DamageType in your game, cast to YourDamageType to read the values.

1 Like

I am clicking “build” on the project solution after changing DamageType.h… I believe DamageType.h is a core Unreal Engine class, so I have also gone through the motions of deleting the intermediates, vs, backup, saved, folders and regenerating the visual studio project files. Then building “clean” in the new solution in VS 2022.

Am I missing an obvious step there?^

Otherwise yes you are right I could make a new class for this, but it felt like a simple solution to just add a variable to the existing class.

I guess you would need to rebuild entire engine and your project for this to work. Even if you do this, updating to latest engine would be a nightmare.

Hey,

A quick one to try with things like this is to change the Base Class of your BP to something else and then change it back to see if it appears. This tends to happen sometimes and can fix your issue.

1 Like

Yes – “build” just re-builds your code, not core classes. You should mark all core class files as read-only on your file system if you can, to avoid mistakes.

If you really do want to mutate the core engine, you have to clone it from git and build the entire engine from scratch. Which some studios do, but it makes future updates harder.

1 Like