Yes of course, here my code:
My .h file
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActorTest.generated.h"
UCLASS()
class MYPROJECT2_API AMyActorTest : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMyActorTest();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UFUNCTION(BlueprintCallable, Category = "Spawning Actor")
AMyActorTest* AMyActorTest::SpawnObjectActor(AActor * ActorReference, UClass * ClassReference, FVector Location, FRotator Rotation);
};
https://forums.unrealengine.com/filedata/fetch?type=thumb&filedataid=116743
And my cpp file:
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyProject2.h"
#include "Engine/Level.h"
#include "MyActorTest.h"
// Sets default values
AMyActorTest::AMyActorTest()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AMyActorTest::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AMyActorTest::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
AMyActorTest* AMyActorTest::SpawnObjectActor(AMyActorTest * ActorReference, UClass * ClassReference, FVector Location, FRotator Rotation) {
UWorld* const World = ActorReference->GetWorld();
//AMyActorTest * MySpawnedActor = TSubclassOf<AActor> MyObject;
AMyActorTest * MySpawnedActor = ActorReference;
AMyActorTest * ActorTest = new AMyActorTest();
if (World != NULL)
{
World->SpawnActor<AMyActorTest>(Location, Rotation);
}
return MySpawnedActor;
}
https://forums.unrealengine.com/filedata/fetch?type=thumb&filedataid=116744
Thanks for your help, i hope i will resolve my problem ^^