Blueprint instance is not being updated

Hello,

I have created a Blueprint derived from a C++ class, and I have added code to create new components and in the Blueprint Editor all seems to be ok, but the already existing instance in my scene is not being updated (after refreshing it), and new instances added to the scene neither have the Blueprint Editor structure.

Blueprint editor:
image

Dropped instance on the scene:
image

I found this post and the solution was to update UE to a certain version, but I’m at version 5.1.1 and it still happens.

Thank you

Have you tried deleting the Intermediate and DerivedDataCache folders and re-running the project? (to clear cache)

Hi @3dRaven , thanks for your reply. Yes, I have tried it and the instances still don’t update! I will try reinstalling 5.1.1 and see if that does the trick, but does not seem like a proper solution XD

Maybe re-parenting the class to the c++ variant again can refresh it? Never tried that myself.

Hi @3dRaven , sorry for the late reply. That did not do it. And neither did reinstalling UE :frowning:

I think I might be onto something. I think the issue is how I’m creating the components…

My base class is a ShooterCharacter, that creates the “Spawn point”, and then I have another class that inherits from “ShooterCharacter” called “IxionCharacter”. This IxionCharacter creates the other two spawn points: “bottom phase 2” and “top phase 2”.
It seems that it’s only creating correctly the base components, the ones from ShooterCharacter, because if I add a new component on the base, it correctly updates the instances.

These are the constructors for the classes:

AShooterCharacter::AShooterCharacter()
{

	PrimaryActorTick.bCanEverTick = true;

    projectileSpawnPoint = CreateDefaultSubobject<USceneComponent>(TEXT("Spawn point"));
	projectileSpawnPoint->SetupAttachment(GetMesh());
}
AIxionCharacter::AIxionCharacter()
{
    projectileSpawnPointTopPhase2 = CreateDefaultSubobject<USceneComponent>(TEXT("Spawn Point Top Phase 2"));
	projectileSpawnPointTopPhase2->SetupAttachment(GetMesh());

    projectileSpawnPointBottomPhase2 = CreateDefaultSubobject<USceneComponent>(TEXT("Spawn Point Bottom Phase 2"));
	projectileSpawnPointBottomPhase2->SetupAttachment(GetMesh());
}

I had tried having the child constructor like this, and it did not work: AIxionCharacter::AIxionCharacter() : Super() { // code }

Hopefully someone can help me with this. Keep in mid that I would like to keep them separated, so only the IxionCharacter class has the additional two spawn points.

Thanks!

Not sure what is wrong with your project but it should work. Perhaps you are not making the properties public or at least protected (so that inheriting classes can see variables)


ShooterGame.zip (25.9 KB)

Shooter Character

ShooterCharacter.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "ShooterCharacter.generated.h"

UCLASS(Blueprintable)
class SHOOTERGAME_API AShooterCharacter : public ACharacter
{
	GENERATED_BODY()

public:
	// Sets default values for this character's properties
	AShooterCharacter();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

	UPROPERTY(BlueprintReadWrite, EditAnywhere);
	USceneComponent* projectileSpawnPoint;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

};

ShooterCharacter.cpp

// Fill out your copyright notice in the Description page of Project Settings.


#include "ShooterCharacter.h"

// Sets default values
AShooterCharacter::AShooterCharacter()
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	projectileSpawnPoint = CreateDefaultSubobject<USceneComponent>(TEXT("Spawn point"));
	projectileSpawnPoint->SetupAttachment(GetMesh());
}

// Called when the game starts or when spawned
void AShooterCharacter::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void AShooterCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

// Called to bind functionality to input
void AShooterCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);

}


IxionCharacter.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "ShooterCharacter.h"
#include "IxionCharacter.generated.h"

/**
 * 
 */
UCLASS(Blueprintable)
class SHOOTERGAME_API AIxionCharacter : public AShooterCharacter
{
	GENERATED_BODY()

public:
		AIxionCharacter();

protected:
	UPROPERTY(BlueprintReadWrite, EditAnywhere)
	USceneComponent* projectileSpawnPointTopPhase2;

	UPROPERTY(BlueprintReadWrite, EditAnywhere)
	USceneComponent* projectileSpawnPointBottomPhase2;


};

IxionCharacter.cpp

// Fill out your copyright notice in the Description page of Project Settings.


#include "IxionCharacter.h"

AIxionCharacter::AIxionCharacter() 
{

	projectileSpawnPointTopPhase2 = CreateDefaultSubobject<USceneComponent>(TEXT("Spawn Point Top Phase 2"));
	projectileSpawnPointTopPhase2->SetupAttachment(GetMesh());

	projectileSpawnPointBottomPhase2 = CreateDefaultSubobject<USceneComponent>(TEXT("Spawn Point Bottom Phase 2"));
	projectileSpawnPointBottomPhase2->SetupAttachment(GetMesh());
}

Hello, thanks again for your reply @3dRaven and for attaching an example. There might be something wrong with my project. Just by reordering some of my code, I managed to get one of the additional positions visible in the instance:

And as you can see in the code below, there is literally no difference between the bottom spawn point and the top spawn point creation/declaration.

IxionCharacter.h

#pragma once

#include "CoreMinimal.h"
#include "ShooterCharacter.h"
#include "IxionCharacter.generated.h"

/**
 * 
 */
UCLASS()
class BULLETHELL_API AIxionCharacter : public AShooterCharacter
{
	GENERATED_BODY()
	
public:
	AIxionCharacter();

	const USceneComponent* GetProjectileSpawnPointTop() const;
	const USceneComponent* GetProjectileSpawnPointBottom() const;
	
protected:
	UPROPERTY(EditAnywhere)
	USceneComponent* projectileSpawnPointTopPhase2;

	UPROPERTY(EditAnywhere)
	USceneComponent* projectileSpawnPointBottomPhase2;

	virtual void HandleDeath();

private:

	int phase = 1;

	void ChangePhase(int newPhase);
};

ShooterCharacter.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "ShooterCharacter.generated.h"

class AGun;

UCLASS()
class BULLETHELL_API AShooterCharacter : public ACharacter
{
	GENERATED_BODY()

public:
	AShooterCharacter();

	virtual void Tick(float DeltaTime) override;

	virtual float TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor* DamageCauser) override;

	void Shoot();

	UFUNCTION(BlueprintPure)
	bool IsDead() const;

	UFUNCTION(BlueprintPure)
	float GetHealthPercent() const;

	// COMPONENTS GETTERS
	const USceneComponent* GetProjectileSpawnPoint() const;

	const float GetMovementSpeed() const;

protected:

	// COMPONENTS
	UPROPERTY(EditAnywhere);
	USceneComponent* projectileSpawnPoint;

	// PROPERTIES
	UPROPERTY(EditDefaultsOnly)
	TSubclassOf<AGun> gunClass;

	UPROPERTY()
	AGun* gun;

	UPROPERTY(EditAnywhere)
	float movementSpeed = 100;

	UPROPERTY(EditDefaultsOnly)
	float maxHealth = 100;

	UPROPERTY(VisibleAnywhere)
	float health;

	UPROPERTY(EditAnywhere, Category="Sprint")
	float sprintMultiplier = 2.0f;

	UPROPERTY(EditAnywhere, Category="Sprint")
	float jumpMultiplier = 1.5f;

	bool isSprinting = false;

	virtual void BeginPlay() override;

	void StartSprint();
	void StopSprint();
	virtual void HandleDeath();
	virtual void DisableCharacter();
};

Also, I have noticed the “Details” panel for the missing component is empty in the blueprint editor.

Anyway, I tried reparenting the blueprint again and this time it worked and instances are correctly updated this time. I really am not liking these kind of errors that are basically random bugs.

Much appreciated!

1 Like