# ProjectileClass is NULL - First Person Template

**URL:** <https://forums.unrealengine.com/t/projectileclass-is-null-first-person-template/411625>\
**Category:** World Creation\
**Tags:** crashes, template-project, unreal-engine, projectile, question, CPP\
**Created:** [December 7, 2017, 10:55am UTC](https://forums.unrealengine.com/t/projectileclass-is-null-first-person-template/411625 "2017-12-07T10:55:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_9b99c8331](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9b99c8331](https://forums.unrealengine.com/u/anonymous_user_9b99c8331)\
**Post date:** [December 7, 2017, 10:55am UTC](https://forums.unrealengine.com/t/projectileclass-is-null-first-person-template/411625/1 "2017-12-07T10:55:09Z")

</div>

Hi all,

I’ve run into a bit of a weird issue. While expanding on the functionality of the c++ first person starter project, at a certain point I built the project, and the ProjectileClass declared in the ProjectCharater.h file was suddenly null at runtime.  
After reverting the code added since the previous functional build, the issue still persisted.

The declaration hasn’t changed:

```
UPROPERTY(EditDefaultsOnly, Category = Projectile)
	TSubclassOf<class ABlink_ArenaProjectile> ProjectileClass;

```

Checking the class at runtime confirms its null value, printing ‘No projectile class’ :

```
void ABlink_ArenaCharacter::BeginPlay()
{
	// Call the base class  
	Super::BeginPlay();

	if (ProjectileClass)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Has projectile class"));
	}
	else
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No projectile class"));
	}
	...
}

```

By altering the UPROPERTY to:

```
UPROPERTY(EditAnywhere, Category = Projectile)

```

and setting the ProjectileClass in the editor, it isn’t null anymore, but crashes on this SetRelativeScale3D call in ABlink\_ArenaProjectile.cpp:

```
UParticleSystemComponent* Explosion = UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ExplosionParticles, GetActorTransform(), true);
	Explosion->SetRelativeScale3D(FVector(4.f));

```

The crash report:

```
Access violation - code c0000005 (first/second chance not available)
UE4Editor_Blink_Arena!ABlink_ArenaProjectile::OnDetonate() [d:\documents\unreal projects\blink_arena\source\blink_arena\blink_arenaprojectile.cpp:75]
UE4Editor_Blink_Arena!ABlink_ArenaProjectile::OnHit() [d:\documents\unreal projects\blink_arena\source\blink_arena\blink_arenaprojectile.cpp:54]
UE4Editor_Blink_Arena!ABlink_ArenaProjectile::execOnHit()
UE4Editor_CoreUObject

```

Removing that line stops any errors, but the projectile mesh and particle system don’t render. It functions as if the projectile has fired (destroys specific types of actors as it has been designed to, with expected travel-time delays, physics etc.)

So in summation: I’m confused.

Tried cleaning and rebuilding the project, stripping out most of the code I’ve added to the classes etc.

Has anyone else come across anything like this?

---

<div class="post-metadata">

**Author:** ![Unzkilled](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Unzkilled](https://forums.unrealengine.com/u/Unzkilled)\
**Post date:** [December 7, 2017, 3:52pm UTC](https://forums.unrealengine.com/t/projectileclass-is-null-first-person-template/411625/2 "2017-12-07T15:52:35Z")

</div>

You need to set a default class for your projectile class don’t be empty, you can do this in constructor or in editor itself. You don’t need to use set world scale, there is an overload of SpawnEmitterAtLocation which accepts scale as parameter:

```
SpawnEmitterAtLocation
(
    const UObject * WorldContextObj...,
    UParticleSystem * EmitterTempla...,
    FVector Location,
    FRotator Rotation,
    FVector Scale,
    bool bAutoDestroy
)
```
