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:
Dropped instance on the scene:
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.
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
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.
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.
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)
// 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:
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.