Weapon Projectile
Introduction
The projectile spawned by weapons
Dependencies
The WeaponProjectile
relies on other components of this plugin to work:
- Logger: Used to log useful information to help you debug any issues you might experience
- Audio: Used to play sound effects either 2D or at a specified location
Components
The WeaponProjectile
uses the following components:
Name | Description | Type |
---|---|---|
CollisionComponent | The projectile spawned by weapons | USphereComponent* |
ProjectileMovementComponent | The projectile movement component used to move the projectile | UProjectileMovementComponent* |
API Reference
Properties
Property | Description | Type | Default Value |
---|---|---|---|
bDestroyOnHit | Should the projectile be destroyed after hitting something? | bool | true |
HitImpulse | The impulse applied to the component that was hit | float | |
DefaultHitReaction | The default hit reaction of the projectile | FWeaponProjectileHitData | |
HitReactions | A list of hit reactions for specific actors | TMap<TSubclassOf<AActor>, FWeaponProjectileHitData> | |
DefaultDecal | The default decal that is spawned when the projectile hits something | TSubclassOf<AWeaponProjectileDecal> | |
Decals | A list of decals for specific actors | TMap<TSubclassOf<AWeaponProjectileDecal>, TSubclassOf<AWeaponProjectileDecal>> |
Functions
Name | Description | Params | Return |
---|---|---|---|
GetCollisionComponent | Get the collision component used by the projectile | USphereComponent* The collision component used by the projectile |
|
GetProjectileMovementComponent | Get the projectile movement component used to move the projectile | UProjectileMovementComponent* The projectile movement component used to move the projectile |
|
NormalImpulse, const FHitResult& HitResult); | Called after the projectile hits something | HitComponent (HitResult);) The component responsible for the hit OtherActor (HitResult);) The actor that was hit OtherComponent (HitResult);) The component that was hit NormalImpulse (FVector) The normal impulse of the hit HitResult (FHitResult&) Result describing the hit |
Blueprint Usage
You can use the WeaponProjectile
using Blueprints by adding one of the following nodes:
- Ultimate Starter Kit > Weapon Projectile > Get Collision Component
- Ultimate Starter Kit > Weapon Projectile > Get Projectile Movement Component
- Ultimate Starter Kit > Weapon Projectile > Normal Impulse, const FHit Result& Hit Result);
C++ Usage
Before you can use the plugin, you first need to enable the plugin in your Build.cs
file:
PublicDependencyModuleNames.Add("USK");
The WeaponProjectile
can now be used in any of your C++ files:
#include "USK/Weapons/WeaponProjectile.h"
void ATestActor::Test()
{
// WeaponProjectile is a pointer to the AWeaponProjectile
USphereComponent* CollisionComponent = WeaponProjectile->GetCollisionComponent();
UProjectileMovementComponent* ProjectileMovementComponent = WeaponProjectile->GetProjectileMovementComponent();
WeaponProjectile->NormalImpulse, const FHitResult& HitResult);(HitComponent, OtherActor, OtherComponent, NormalImpulse, HitResult);
}