I try to spawn a custom actor using C++,but it do not work,is there someone can help me?thanks!

I try to spawn a custom actor using C++,but it do not work,is there someone can help me?thanks!
here is my actor:
head file:

#pragma once

#include "GameFramework/Actor.h"
#include "PlaceableActor.generated.h"

UCLASS()
class YC_API APlaceableActor : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	APlaceableActor();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	UPROPERTY(VisibleDefaultsOnly,BlueprintReadOnly,Category = Placeable)
	TSubobjectPtr<USphereComponent>	BaseCollisionCom;
	UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite, Category = Placeable)
	TSubobjectPtr<UStaticMeshComponent> PlaceableMesh;

	UFUNCTION()
	void OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
};

CPP file:

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

#include "YC.h"
#include "PlaceableActor.h"
#include "Engine.h"

// Sets default values
APlaceableActor::APlaceableActor()
{
	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("OBJECT CREATE..."));
	}
 	// 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;

	BaseCollisionCom = CreateDefaultSubobject<USphereComponent>(TEXT("BaseCollisionCom"));
	BaseCollisionCom->OnComponentHit.AddDynamic(this, &APlaceableActor::OnHit);
	RootComponent = BaseCollisionCom;

	PlaceableMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PlaceableMesh"));

	PlaceableMesh->SetSimulatePhysics(true);
	PlaceableMesh->AttachTo(RootComponent);
}

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

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

}

void APlaceableActor::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HIT"));
	}
}

i use SpawnActor to create it , but the actor do not spawn sucess.
Can someone tell me where am i wrong?
Thanks!!!

UPROPERTY(EditDefaultsOnly, Category = Placeable)
TSubclassOf PlaceableActorClass;

UWorld* const World = GetWorld();
World->SpawnActor(PlaceableActorClass, SpawnLocation, SpawnRotation);

Format your post… it will be easier to help then…

sorry,it format now.

yes,i use ue4.7.3, here is the spawn code,it trigger by key event:
UPROPERTY(EditDefaultsOnly, Category = Placeable)
TSubclassOf PlaceableActorClass;

UWorld* const World = GetWorld();
World->SpawnActor(PlaceableActorClass, SpawnLocation, SpawnRotation);

sorry , i do not konw how to format it…

it really triggered.I will try : GetWorld()->SpawnActor[](APlacableActor::StaticClass(), SpawnLocation, SpawnRotation);
thank you!

can we see how you spawn it, and where you spawn???
and i think if you use UE4.6 ++, you don’t need to use TSharedPtr anymore. just straight pointer :slight_smile:

can you make a breakpoint in you spawn code, just to make sure it really triggered.
and btw your spawn code seems not right… i think it would be like this ::

maybe you can make it like this ::
GetWorld()->SpawnActor"<“APlacableActor”>"(APlacableActor::StaticClass(), SpawnLocation, SpawnRotation);

just try heheheh (delete the “”)

AArrowProjectile* arrow = world->SpawnActor(arrowSpawnPoint, CameraRotation, spawnParam);

it is ok now ,thanks a lot.

Would you mind posting your fix to your problem for other users and do this as an answer not as a comment so you can mark this questions resolved? (: Thanks in advance