i’m following part 3.1 of the unreal fps tutorial, and am trying to set the initial velocity for the projectile using a function. however, i keep getting the following errors:
- pointer to incomplete class type is not allowed at line 17
- argument of type “USpehreComponent *” is incompatible with parameter of type “USceneComponent *” at line 24
- a value of type “USpehreComponent *” cannot be assigned to an entity of type “USceneComponent *” line 19
could anyone help me? here’s my projectile.cpp file:
#include "FPSProjectile.h"
#include "CoreMinimal.h"
#include "Collision.h"
#include "Engine.h"
// Sets default values
AFPSProjectile::AFPSProjectile()
{
// 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;
//we're using a sphere as a visual represebtation for the projectile.
CollisionComponent = CreateDefaultSubobject<USpehreComponent>(TEXT("Collision component"));
//set the collision radius of the sphere.
CollisionComponent->InitSphereRadius(15.0f);
//set root component to the sphere component.
= CollisionComponent;
//ProjectileMovementComponent will be responsible for the movement oof the projectile.
ProjectileMovementComponent = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("Projectile movement component"));
ProjectileMovementComponent->SetUpdatedComponent(CollisionComponent);
ProjectileMovementComponent->InitialSpeed = 3000.0f;
ProjectileMovementComponent->MaxSpeed = 3000.0f;
ProjectileMovementComponent->bRotationFollowsVelocity = true;
ProjectileMovementComponent->bShouldBounce = true;
ProjectileMovementComponent->Bounciness = 0.3f;
}
// Called when the game starts or when spawned
void AFPSProjectile::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AFPSProjectile::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
//implementation for the function that sets initial speed for the projectile
void AFPSProjectile::FireInDirection(const FVector &ShootDirection)
{
ProjectileMovementComponent->Velocity = ShootDirection * ProjectileMovementComponent->InitialSpeed;
}
my header file:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "FPSProjectile.generated.h"
UCLASS()
class BASICFPS_API AFPSProjectile : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AFPSProjectile();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
//sphere component for the projectile.
UPROPERTY(VisibleDefaultsOnly, category = Projectile)
class USpehreComponent * CollisionComponent;
//movement component for the projectile.
UPROPERTY(VisibleDefaultsOnly, Category = Movement)
class UProjectileMovementComponent * ProjectileMovementComponent;
//function that sets initial velocity of projectile.
void FireInDirection(const FVector &ShootDirection);
};
part of the tutorial i’m on:
https://docs.unrealengine.com/latest/INT/Programming/Tutorials/FirstPersonShooter/3/1/index.html