Dispite efforts, I can't get my projectile movement component to work.

Hello,

I have been trying to get my projectile to work for days now. For some reason, despite me following the exact same steps I did whenever I first took the GameDev.tv class. To break down what I have:

ice_screenshot_20240610-184800

This is the constructor I have for my projectile. It’s derived from C++. You’ll find the code from the constructor below.

AProjectile::AProjectile()
{
	PrimaryActorTick.bCanEverTick = false;

	RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Projecile Root Component"));

	CollisionMesh = CreateDefaultSubobject<UBoxComponent>(TEXT("Collision"));
	CollisionMesh->SetupAttachment(RootComponent);

	ShotMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Shot Mesh"));
	ShotMesh->SetupAttachment(CollisionMesh);

	ProjectileMovementComp = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("Projectile Movement Component"));
	ProjectileMovementComp->SetUpdatedComponent(CollisionMesh);
	ProjectileMovementComp->InitialSpeed = 3000;
	ProjectileMovementComp->MaxSpeed = 3000;
	ProjectileMovementComp->ProjectileGravityScale = 0;
	ProjectileMovementComp->bRotationFollowsVelocity = true;
}

For the sake of debugging, I’ve set the static mesh and the collision box to ignore all channels, in case it happened to be hitting something when spawned.

As for the firing function:

void ABasePawn::Fire(TSubclassOf<class AProjectile> Projectile)
{
	if (PrimaryProjectileGauge >= 1)
	{
		FActorSpawnParameters SpawnParameters;
		SpawnParameters.Owner = this;
		SpawnParameters.Instigator = this;

		AProjectile* FiredProjectile = GetWorld()->SpawnActor<AProjectile>(
			Projectile,
			ProjectileSpawnPoint->GetComponentLocation(),
			ProjectileSpawnPoint->GetComponentRotation(),
			SpawnParameters
		);
		FiredProjectile->SetOwner(this);
		PrimaryProjectileGauge -= 1;
	}
}

The spawn point derives from a component that is part of ABasePawn. I’ve made sure that the projectile isn’t immediately colliding with the mesh of the pawn by moving it a sizeable distance away from the pawn. Alas, I don’t think that’d make a difference, since I already disabled all of the collision.

Finally, I made sure that the collision mesh and the static mesh were set to ‘Moveable’, and that the projectile movement component was set to ‘Auto Activate’.

Here’s the result:

ice_video_20240610-185442_edit_0

Any help is much appreciated.