Error compiling FPS Tutorial c++

Hi,
I’m new to unreal engine and wanted to do this tutorial: A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums , but I’m getting an error in that part: Adding Projectiles and Shooting

Here’s my code in FPSProjectile.h:

#pragma once

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

/**
 * 
 */
UCLASS()
class FPSPROJECT_API AFPSProjectile : public AActor
{
	GENERATED_BODY()
public:
	AFPSProjectile(const FObjectInitializer& ObjectInitializer)
	/** Sphere collision component */
	UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
	USphereComponent* CollisionComp;

	/** Projectile movement component */
	UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Movement)
	UProjectileMovementComponent* ProjectileMovement;
	void InitVelocity(const FVector& ShootDirection);
	
};

and here’s the one in FPSProjectile.cpp:

#include "FPSProject.h"
#include "FPSProjectile.h"

void AFPSProjectile::AFPSProjectile(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
	// Use a sphere as a simple collision representation
	CollisionComp = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("SphereComp"));
	CollisionComp->InitSphereRadius(15.0f);
	RootComponent = CollisionComp;

	// Use a ProjectileMovementComponent to govern this projectile's movement
	ProjectileMovement = ObjectInitializer.CreateDefaultSubobject<UProjectileMovementComponent>(this, TEXT("ProjectileComp"));
	ProjectileMovement->UpdatedComponent = CollisionComp;
	ProjectileMovement->InitialSpeed = 3000.f;
	ProjectileMovement->MaxSpeed = 3000.f;
	ProjectileMovement->bRotationFollowsVelocity = true;
	ProjectileMovement->bShouldBounce = true;
	ProjectileMovement->Bounciness = 0.3f;
}

void InitVelocity(const FVector& ShootDirection)
{
	if (ProjectileMovement){
		// set the projectile's velocity to the desired direction
		ProjectileMovement->Velocity = ShootDirection * ProjectileMovement->InitialSpeed;
	}
}

Those are the error’s I’m getting:
http://pastebin.com/vSTUDiLC

error C3646: ‘USphereComponent’ : unknown override specifier

Thanks!

at line 14 in the FPSProjectile.h, add a semi-colon at the end.

Didn’t work: Error 1 error : In FPSProjectile: Extra ‘;’ before ‘public’

sorry there was a problem in the cpp as well but i didn’t notice, there is “void” before the constructor, remove that!

Should be: AFPSProjectile::AFPSProjectile(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)

■■■■ another thing, it’s a bit late here man :smiley:

the function InitVelocity should be defined like this in the cpp:

void AFPSProjectile::InitVelocity(const FVector& ShootDirection)
 {
     if (ProjectileMovement){
         // set the projectile's velocity to the desired direction
         ProjectileMovement->Velocity = ShootDirection * ProjectileMovement->InitialSpeed;
     }
 }

Thanks, also added void AFPSProjectile::InitVelocity instead of void InitVelocity but somehow still getting that error

can you post the new compilation log?

Here’s the new log: fsdtgret - Pastebin.com

Before the different pointers like “USphereComponent*”: you should have the modifier “class” as this is a forward declaration and the compiler doesn’t yet know what a USphereComponent is.

class USphereComponent* CollisionComp;
class UProjectileMovementComponent* ProjectileMovement;

I’m not sure if you added the semi-colon after the constructor in the header file though cause it’s still mentioning it.

Thanks for helping but USphereComponent doesn’t seem to exist somehow, but all the other one’s seem to work. Getting this when adding class: dsadsadg - Pastebin.com

Here man, at line 14 in the header file.

should be like this:
AFPSProjectile(const FObjectInitializer& ObjectInitializer);

you need a semi-colon “;” at the end. That’s why it’s saying USphereComponent should be "preceded by “;”

Wow thanks for the help, works fine now :smiley: