# How to fix : Bullet don't spawn

**URL:** <https://forums.unrealengine.com/t/how-to-fix-bullet-dont-spawn/449952>\
**Category:** Community & Industry Discussion\
**Tags:** shooting, error, unreal-engine, CPP, question\
**Created:** [June 2, 2019, 6:56am UTC](https://forums.unrealengine.com/t/how-to-fix-bullet-dont-spawn/449952 "2019-06-02T06:56:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FilsDeCroissant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FilsDeCroissant](https://forums.unrealengine.com/u/FilsDeCroissant)\
**Post date:** [June 1, 2019, 8:20pm UTC](https://forums.unrealengine.com/t/how-to-fix-bullet-dont-spawn/449952/1 "2019-06-01T20:20:51Z")

</div>

Can I Up This ?

---

<div class="post-metadata">

**Author:** ![FilsDeCroissant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FilsDeCroissant](https://forums.unrealengine.com/u/FilsDeCroissant)\
**Post date:** [June 2, 2019, 6:56am UTC](https://forums.unrealengine.com/t/how-to-fix-bullet-dont-spawn/449952/2 "2019-06-02T06:56:23Z")

</div>

Hello,  
I was following a tutorial to start UE4 with C++ (and blueprints)  
But when I wanted to test if my code was correct, the pawn (UlitmatePawn) wasn’t shooting the Bullet (Actor)

Can somebody please tall me what’s wrong with my code and me ?

Thank’s a lot helping me.  
Shawrex

Bullet.cpp :

```
#include "Bullet.h"

#include "Classes/GameFrameWork/ProjectileMovementComponent.h"
#include "Classes/Components/StaticMeshComponent.h"

// Sets default values
ABullet::ABullet()
{
 	// 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;

	BulletMesh = CreateDefaultSubobject<UStaticMeshComponent>("BulletMesh");

	SetRootComponent(BulletMesh);

	BulletMovement = CreateDefaultSubobject<UProjectileMovementComponent>("BulletMovement");
	BulletMovement->InitialSpeed = 2000.f;
	BulletMovement->MaxSpeed = 2000.f;

}

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

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

}

```

Bullet.h :  
#pragma once

```
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Bullet.generated.h"

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

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

	UPROPERTY(EditAnywhere, Category = "Components")
	UStaticMeshComponent* BulletMesh;

	UPROPERTY(EditAnywhere, Category = "Components")
	class UProjectileMovementComponent* BulletMovement;

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

};

```

UltimatePawn.cpp :

```
#include "UltimatePawn.h"
#include "Bullet.h"

#include "Classes/Components/InputComponent.h"
#include "Classes/GameFramework/FloatingPawnMovement.h"
#include "Classes/GameFramework/SpringArmComponent.h"
#include "Classes/Camera/CameraComponent.h"
#include "Runtime/Engine/Classes/Engine/World.h"

// Sets default values
AUltimatePawn::AUltimatePawn()
{
 	// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	FloatingPawnMovement = CreateAbstractDefaultSubobject<UFloatingPawnMovement>("PawnMovement");

	StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>("StaticMeshComponent");

	CameraArm = CreateDefaultSubobject<USpringArmComponent>("CameraSpringArm");
	CameraArm->SetupAttachment(StaticMesh);
	CameraArm->TargetArmLength = 500.f;

	Camera = CreateAbstractDefaultSubobject<UCameraComponent>("CameraComponent");
	Camera->SetupAttachment(CameraArm);

	SetRootComponent(StaticMesh);

	bUseControllerRotationYaw = true;
	bUseControllerRotationPitch = true;

}

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

```

Finally,  
UltimatePawn.h :  
#pragma once

```
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "UltimatePawn.generated.h"

UCLASS()
class ULTIMATE_API AUltimatePawn : public APawn
{
	GENERATED_BODY()

public:
	// Sets default values for this pawn's properties
	AUltimatePawn();

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

	void MoveFoward(float Amount);
	void MoveRight(float Amount);
	void Turn(float Amount);
	void LookUp(float Amount);

	void Shoot();

	UPROPERTY(EditAnywhere, Category = "Shooting")
	TSubclassOf<class ABullet> BulletClass;

	class UFloatingPawnMovement* FloatingPawnMovement;

	UPROPERTY(EditAnywhere, Category = "Components")
	UStaticMeshComponent* StaticMesh;

	UPROPERTY(EditAnywhere, Category = "Components")
	class UCameraComponent* Camera;

	UPROPERTY(EditAnywhere, Category = "Components")
	class USpringArmComponent* CameraArm;

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

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

};
```

---

<div class="post-metadata">

**Author:** ![Lardo\_Deepdelver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lardo\_Deepdelver](https://forums.unrealengine.com/u/Lardo_Deepdelver)\
**Post date:** [June 5, 2019, 7:29am UTC](https://forums.unrealengine.com/t/how-to-fix-bullet-dont-spawn/449952/3 "2019-06-05T07:29:36Z")

</div>

where are you spawning your bullet?

Normally I would expect a shooting function in your pawn

called from a trigger

setup in SetupPlayerInputComponent

---

<div class="post-metadata">

**Author:** ![Terricon4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Terricon4](https://forums.unrealengine.com/u/Terricon4)\
**Post date:** [June 5, 2019, 7:36am UTC](https://forums.unrealengine.com/t/how-to-fix-bullet-dont-spawn/449952/4 "2019-06-05T07:36:58Z")

</div>

Also what are the spawn settings for collisions, if not set to ignore collisions and spawn anyway then if you are spawning it from a source that might be inside of the gun barrel or something that it can collide with, then the projectile might not be spawning since it considers that location invalid.
