Here are my changes:
in Build.cs:
using UnrealBuildTool;
public class FPS_2 : ModuleRules
{
public FPS_2(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay","Niagara" });
PrivateDependencyModuleNames.AddRange(new string[] { "Niagara" });
}
}
in uproject:
{
"FileVersion": 3,
"EngineAssociation": "4.27",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "FPS_2",
"Type": "Runtime",
"LoadingPhase": "Default"
},
{
"Name": "Niagara",
"Type": "Runtime",
"Enabled": true
}
]
}
in .h:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "FPS_2Projectile.generated.h"
class USphereComponent;
class UProjectileMovementComponent;
UCLASS(config=Game)
class AFPS_2Projectile : public AActor
{
GENERATED_BODY()
/** Sphere collision component */
UPROPERTY(VisibleDefaultsOnly, Category=Projectile)
USphereComponent* CollisionComp;
/** Projectile movement component */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Movement, meta = (AllowPrivateAccess = "true"))
UProjectileMovementComponent* ProjectileMovement;
public:
AFPS_2Projectile();
/** called when projectile hits something */
UFUNCTION()
void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
/** Returns CollisionComp subobject **/
USphereComponent* GetCollisionComp() const { return CollisionComp; }
/** Returns ProjectileMovement subobject **/
UProjectileMovementComponent* GetProjectileMovement() const { return ProjectileMovement; }
class UNiagaraSystem* NiagaraSystemAsset;
private:
void BeginPlay();
class UNiagaraComponent* NiagaraSystemInstance;
};
in .cpp:
#include "FPS_2Projectile.h"
#include "GameFramework/ProjectileMovementComponent.h"
#include "Components/SphereComponent.h"
#include "NiagaraComponent.h"
#include "NiagaraFunctionLibrary.h"
#include "NiagaraSystem.h"
...
void AFPS_2Projectile::BeginPlay() {
ParticleSystemInstance = UNiagaraFunctionLibrary::SpawnSystemAttached(
ParticleSystemAsset, RootComponent, NAME_None,
FVector::ZeroVector, FRotator::ZeroRotator, FVector::OneVector,
EAttachLocation::Type::KeepWorldPosition, false,
ENCPoolMethod::None);
}
…
but,i see error:
…
1> [11/15] FPS_2Character.cpp
1> [12/15] FPS_2Projectile.cpp
1>D:\Program Files\Epic Games\UE_4.27\Engine\Plugins\FX\Niagara\Source\Niagara\Public\NiagaraTypes.h(21): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
…
how to fix ?