Questions in topic: "first person template"https://answers.unrealengine.com/questions/topics/single/29038.html
The latest questions for the topic "first person template"First person player continues sliding to the left/right after collision and adding the widget to the viewporthttps://answers.unrealengine.com/questions/858817/first-person-player-continues-sliding-to-the-leftr.html
I made a widget blueprint and an object blueprint with the box collision in the first person template. When the player approaches the object the widget is added to the viewport. The widget is set to the UI Only Mode. As i understand in this mode no any player movement is allowed and i can operate only in the widget. But when the player collides with the object and the widget is brought to the screen it continues sliding to the either side till the next obstacle. I tried to use the Stop Movement function but it didn’t help. How can I fix this?widgetmovementfirst person templateTue, 18 Dec 2018 15:24:44 GMTBaktybekHow to play different footstep sounds at different speedshttps://answers.unrealengine.com/questions/839283/how-to-play-different-footstep-sounds-at-different.html
So I understand how to play footstep sounds using the first person running animation and adding play sound nodes on the timeline, I also know how to play different sounds based on the material you're walking on. But what I don't know is how to play footstep sounds at different speeds. Lets say I'm crouching. I want the footstep sounds to sound slower, and when I'm running, I want them to sound faster. How do I go about doing this?blueprintssoundfirst person templatefootstepsplay soundSat, 20 Oct 2018 21:21:30 GMTDaveDaveyCustom Projectile Not Spawning in the Correct Location UE4 SHOOTER-GAME First Person Shooterhttps://answers.unrealengine.com/questions/833147/custom-projectile-not-spawning-in-the-correct-loca.html
For this project, I have used the UE4 SHOOTER-GAME sample as a template.
I have been able to get not only have a grenade spawn in the correct location in front of the Player using Blueprint, but also travel in the respective forwards direction (no matter where the Player is looking and following the intended mechanics for such (based off the Halo plasma-grenade, exploding after 3 seconds from hitting a target, bouncing off entities that are not Players whilst sticking to Players when impacting them).
I have attempted to implement such functionality in C++, creating a custom class (ProjPlasmaGrenade), to handle this and I am unable to test out the other functionality of the grenade, aside from spawning, as it won't spawn in the intended location (in front of where the Player is looking).![alt text][1]
In the above image, is the PlayerPawn Blueprint, with a sphere component selected for where the grenades should spawn relative to the Player's pawn (near the end of their rifle in this preview).
In the image below, is the ProjPlasmaGrenade Blueprint for the plasma-grenade, with the Body (main visual) component selected (it is the child of the collision sphere):
'![alt text][2]
Just below, is a screenshot of the Player holding the plasma-grenade, as intended (1st-person perspective):
![alt text][3]
Next, is the collision-component of the plasma-grenade (the root-component), for where it should spawn in the world:
![alt text][4]
Next comes the Body component of the plasma-grenade, quite far away from the root-component and under a static-mesh of the level construct:
![alt text][5]
I have also included the method that spawns a grenade, into the game world just below:
void AShooterWeapon_Projectile::SpawnGrenade()
{
// Get a reference to the Player pawn:
AShooterCharacter* WeaponOwner = GetPawnOwner();
// To hold the camera manager actor (there is only one):
TArray<AActor*> CameraManagerActor;
UGameplayStatics::GetAllActorsOfClass(this, APlayerCameraManager::StaticClass(), CameraManagerActor);
CameraManagerReference = Cast<AShooterPlayerCameraManager>(CameraManagerActor[0]);
FRotator CameraRotation;
if (CameraManagerReference)
{
CameraRotation = CameraManagerReference->GetActorTransformComponentTransform().GetRotation().Rotator();
}
// To offset the placement in the correct direction:
FVector RotatedOffset = CameraRotation.RotateVector(GrenadeSpawnOffset);
FVector SpawnLocation = WeaponOwner->GrenadeSpawnPoint->GetComponentLocation();
FTransform SpawnTransform = FTransform(RotatedOffset.Rotation(), SpawnLocation, DefaultSpawnScale);
SpawnedPlasmaGrenade = Cast<AProjPlasmaGrenade>(UGameplayStatics::BeginSpawningActorFromBlueprint(this, ProjectileBlueprint, SpawnTransform, false));
if (SpawnedPlasmaGrenade)
{
SetActorHiddenInGame(true);
UGameplayStatics::FinishSpawningActor(SpawnedPlasmaGrenade, SpawnTransform);
// To prevent it being cleaned up here too:
SpawnedPlasmaGrenade->SetFlags(EObjectFlags::RF_MarkAsRootSet);
}
}
For added clarity, what I believe are the key classes related to this issue, are shown below:
ShooterWeapon_Projectile.h
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "ShooterWeapon.h"
#include "GameFramework/DamageType.h" // for UDamageType::StaticClass()
#include "ShooterWeapon_Projectile.generated.h"
USTRUCT()
struct FProjectileWeaponData
{
GENERATED_USTRUCT_BODY()
/** projectile class */
UPROPERTY(EditDefaultsOnly, Category=Projectile)
TSubclassOf<class AShooterProjectile> ProjectileClass;
/** life time */
UPROPERTY(EditDefaultsOnly, Category=Projectile)
float ProjectileLife;
/** damage at impact point */
UPROPERTY(EditDefaultsOnly, Category=WeaponStat)
int32 ExplosionDamage;
/** radius of damage */
UPROPERTY(EditDefaultsOnly, Category=WeaponStat)
float ExplosionRadius;
/** type of damage */
UPROPERTY(EditDefaultsOnly, Category=WeaponStat)
TSubclassOf<UDamageType> DamageType;
/** defaults */
FProjectileWeaponData()
{
ProjectileClass = NULL;
ProjectileLife = 10.0f;
ExplosionDamage = 100;
ExplosionRadius = 300.0f;
DamageType = UDamageType::StaticClass();
}
};
// A weapon that fires a visible projectile
UCLASS(Abstract)
class AShooterWeapon_Projectile : public AShooterWeapon
{
GENERATED_UCLASS_BODY()
/** apply config on projectile */
void ApplyWeaponConfig(FProjectileWeaponData& Data);
protected:
/** weapon config */
UPROPERTY(EditDefaultsOnly, Category=Config)
FProjectileWeaponData ProjectileConfig;
/** Weapons that are not rocket weapons are to be handled differently. */
UPROPERTY(EditDefaultsOnly, Category = Flags)
bool IsCustomWeapon;
/** For the transformation of certain projectile weapons. */
FTransform CustomProjectileTransformation;
//(X = 70.000000, Y = 0.000000, Z = 80.000000)
public:
// Constant Values:
/** For the plasma grenade weapon. */
// Tried spawning the grenades at a socket on the skeltal mesh,
// but this would not spawn the grenades where it would make sense to.
const FName GRENADE_SPAWN_POINT = FName("GrenadePoint");
// For the name of the plasma grenade, to identify it:
const FName PLASMA_GRENADE_ID = FName("PlasmaGrenade");
// Custom lifetime after impact, after which, it will explode:
const float PLASMA_GRENADE_FUSE_TIME_AFTER_IMPACT = 3000.0f;
// For a tag used to identify a sphere used to spawn the grenades at:
const FName DEFAULT_PROJECTILE_SPAWN_POINT = FName("ProjectileSpawnPoint");
// Plasma grenade usage:
/**
* For whether the Player can spawn this grenade or not
* (can only use the plasma grenade weapon if the spawned
* plasma grenade is invalid).
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WeaponManagement)
class AProjPlasmaGrenade* SpawnedPlasmaGrenade;
/** The default scale to use when spawning the plasma grenade into the level. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WeaponManagement)
FVector DefaultSpawnScale;
/** For use in spawning the grenade at the correct position. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WeaponManagement)
class AShooterPlayerCameraManager* CameraManagerReference;
/** For use in spawning grenades or other throwable projectiles. */
UPROPERTY(EditDefaultsOnly, Category = Projectile)
UBlueprint* ProjectileBlueprint;
/**
* To clean up the plasma grenade pointer of this class
* (so grenades can be spawned again).
*/
void DestroyGrenade();
/**
* For suitable off-setting the spawn point of the grenade from the weapon
* (so that spawning the grenade will not fail).
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WeaponManagement)
FVector GrenadeSpawnOffset;
protected:
//////////////////////////////////////////////////////////////////////////
// Weapon usage
/** To handle spawning the grenade. */
void SpawnGrenade();
/**
* [local] weapon specific fire implementation
*
*/
virtual void FireWeapon(FTransform TargetProjectileSpawnTransformation) override;
/** For plasma grenades. */
void HandleGrenadeThrowing();
/** spawn projectile on server */
UFUNCTION(reliable, server, WithValidation)
void ServerFireProjectile(FVector Origin, FVector_NetQuantizeNormal ShootDir);
};
ShooterWeapon_Projectile.cpp
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "ShooterGame.h"
#include "Weapons/ShooterWeapon_Projectile.h"
#include "Player/ShooterPlayerCameraManager.h"
#include "Player/ShooterCharacter.h"
#include "ProjPlasmaGrenade.h"
//#include ""
#include "Weapons/ShooterProjectile.h"
AShooterWeapon_Projectile::AShooterWeapon_Projectile(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
// For the plasma grenade:
DefaultSpawnScale = FVector(0.25f, 0.25f, 0.25f);
GrenadeSpawnOffset = FVector(100.0f, 0.0f, -10.0f);
}
//////////////////////////////////////////////////////////////////////////
// Weapon usage
void AShooterWeapon_Projectile::FireWeapon(FTransform TargetProjectileSpawnTransformation)
{
// In a previous attempt to spawn the plasma grenade at the correct location:
CustomProjectileTransformation = TargetProjectileSpawnTransformation;
// For plasma-grenades:
if (IsCustomWeapon && WeaponConfig.WeaponName == PLASMA_GRENADE_ID)
{
HandleGrenadeThrowing();
return;
}
FVector ShootDir = GetAdjustedAim();
FVector Origin = GetMuzzleLocation();
// trace from camera to check what's under crosshair
const float ProjectileAdjustRange = 10000.0f;
const FVector StartTrace = GetCameraDamageStartLocation(ShootDir);
const FVector EndTrace = StartTrace + ShootDir * ProjectileAdjustRange;
FHitResult Impact = WeaponTrace(StartTrace, EndTrace);
// and adjust directions to hit that actor
if (Impact.bBlockingHit)
{
const FVector AdjustedDir = (Impact.ImpactPoint - Origin).GetSafeNormal();
bool bWeaponPenetration = false;
const float DirectionDot = FVector::DotProduct(AdjustedDir, ShootDir);
if (DirectionDot < 0.0f)
{
// shooting backwards = weapon is penetrating
bWeaponPenetration = true;
}
else if (DirectionDot < 0.5f)
{
// check for weapon penetration if angle difference is big enough
// raycast along weapon mesh to check if there's blocking hit
FVector MuzzleStartTrace = Origin - GetMuzzleDirection() * 150.0f;
FVector MuzzleEndTrace = Origin;
FHitResult MuzzleImpact = WeaponTrace(MuzzleStartTrace, MuzzleEndTrace);
if (MuzzleImpact.bBlockingHit)
{
bWeaponPenetration = true;
}
}
// This is considered to be true (1) for grenades being instantiated:
if (bWeaponPenetration && !IsCustomWeapon)
{
// spawn at crosshair position
Origin = Impact.ImpactPoint - ShootDir * 10.0f;
}
else
{
// adjust direction to hit
ShootDir = AdjustedDir;
}
}
ServerFireProjectile(Origin, ShootDir);
}
// This custom method was implemented for handling the grenades being thrown (different than for other projectiles):
void AShooterWeapon_Projectile::HandleGrenadeThrowing()
{
if (!SpawnedPlasmaGrenade)
{
SpawnGrenade();
}
}
void AShooterWeapon_Projectile::DestroyGrenade()
{
if (SpawnedPlasmaGrenade)
{
//SpawnedPlasmaGrenade->ConditionalBeginDestroy();
}
}
void AShooterWeapon_Projectile::SpawnGrenade()
{
// Get a reference to the Player pawn:
AShooterCharacter* WeaponOwner = GetPawnOwner();
// To hold the camera manager actor (there is only one):
TArray<AActor*> CameraManagerActor;
UGameplayStatics::GetAllActorsOfClass(this, APlayerCameraManager::StaticClass(), CameraManagerActor);
CameraManagerReference = Cast<AShooterPlayerCameraManager>(CameraManagerActor[0]);
FRotator CameraRotation;
if (CameraManagerReference)
{
CameraRotation = CameraManagerReference->GetActorTransformComponentTransform().GetRotation().Rotator();
}
// To offset the placement in the correct direction:
FVector RotatedOffset = CameraRotation.RotateVector(GrenadeSpawnOffset);
FVector SpawnLocation = WeaponOwner->GrenadeSpawnPoint->GetComponentLocation();
FTransform SpawnTransform = FTransform(RotatedOffset.Rotation(), SpawnLocation, DefaultSpawnScale);
SpawnedPlasmaGrenade = Cast<AProjPlasmaGrenade>(UGameplayStatics::BeginSpawningActorFromBlueprint(this, ProjectileBlueprint, SpawnTransform, false));
if (SpawnedPlasmaGrenade)
{
SetActorHiddenInGame(true);
UGameplayStatics::FinishSpawningActor(SpawnedPlasmaGrenade, SpawnTransform);
// To prevent it being cleaned up here too:
SpawnedPlasmaGrenade->SetFlags(EObjectFlags::RF_MarkAsRootSet);
}
}
bool AShooterWeapon_Projectile::ServerFireProjectile_Validate(FVector Origin, FVector_NetQuantizeNormal ShootDir)
{
return true;
}
void AShooterWeapon_Projectile::ServerFireProjectile_Implementation(FVector Origin, FVector_NetQuantizeNormal ShootDir)
{
FTransform SpawnTM(ShootDir.Rotation(), Origin);
AShooterProjectile* Projectile = Cast<AShooterProjectile>(UGameplayStatics::BeginDeferredActorSpawnFromClass(this, ProjectileConfig.ProjectileClass, SpawnTM));
if (Projectile)
{
Projectile->Instigator = Instigator;
Projectile->SetOwner(this);
Projectile->InitVelocity(ShootDir);
UGameplayStatics::FinishSpawningActor(Projectile, SpawnTM);
}
}
void AShooterWeapon_Projectile::ApplyWeaponConfig(FProjectileWeaponData& Data)
{
Data = ProjectileConfig;
}
/**
REFERENCE.
*/
//AShooterCharacter* OwnerCharacter = GetPawnOwner();
//UStaticMeshComponent* GrenadeSpawnLocationReference = Cast<UStaticMeshComponent>(OwnerCharacter->GetComponentByClass(UStaticMeshComponent::StaticClass()));
//USkeletalMeshComponent* FirstPersonMeshReference = GetPawnOwner()->GetPawnMesh();
//if (ProjectileConfig.ProjectileClass && FirstPersonMeshReference)
//{
// // SOLVE ISSUE HERE
//
// // Not quite, adjust this to spawn the projectile for the character's facing
// FVector TargetPosition = FirstPersonMeshReference->GetSocketLocation(GRENADE_SPAWN_POINT) + OwnerCharacter->GetActorForwardVector();
// FTransform SpawnTransform = FTransform(GrenadeSpawnLocationReference->GetComponentToWorld());
// AShooterProjectile* GrenadeProjectile = Cast<AShooterProjectile>(UGameplayStatics::BeginDeferredActorSpawnFromClass(
// this, ProjectileConfig.ProjectileClass, SpawnTransform));
// if (GrenadeProjectile)
// {
// GrenadeProjectile->Instigator = Instigator;
// GrenadeProjectile->SetOwner(this);
//
// UGameplayStatics::FinishSpawningActor(GrenadeProjectile, SpawnTransform);
// }
//}
ProjPlasmaGrenade.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "ProjPlasmaGrenade.generated.h"
USTRUCT()
struct FThrowableWeaponData
{
GENERATED_USTRUCT_BODY()
/** The damage dealt by this weapon in the base damage radius. */
UPROPERTY(EditDefaultsOnly, Category = ThrowableProjectile)
float BaseDamage;
/** The minimum possible damage out to MaximumDamageRadius. */
UPROPERTY(EditDefaultsOnly, Category = ThrowableProjectile)
float MinimumDamage;
/** The base damage dealt to actors out to this value, from the origin (no falloff). */
UPROPERTY(EditDefaultsOnly, Category = ThrowableProjectile)
float BaseDamageRadius;
/** The base damage factoring in the damage falloff, is dealt to actors out to this value, from the origin. */
UPROPERTY(EditDefaultsOnly, Category = ThrowableProjectile)
float MaximumDamageRadius;
/** Damage outside the base damage radius, is scaled by this value up to the maximum damage radius. */
UPROPERTY(EditDefaultsOnly, Category = ThrowableProjectile)
float DamageFalloff;
// For default values:
FThrowableWeaponData()
{
BaseDamage = 100.0f;
MinimumDamage = 5.0f;
BaseDamageRadius = 396.0f;
MaximumDamageRadius = 1290.0f;
DamageFalloff = 0.1f;
}
};
UCLASS()
class SHOOTERGAME_API AProjPlasmaGrenade : public AActor
{
GENERATED_BODY()
public:
/** Set-up this projectile. */
AProjPlasmaGrenade(const FObjectInitializer& ObjectInitializer);
/** For the main visible component of this projectile. */
UPROPERTY(EditDefaultsOnly, Category = VisualComponent)
UStaticMeshComponent* Body;
/** To handle this actor's movement, as a projectile. */
UPROPERTY(EditDefaultsOnly, Category = Movement)
UProjectileMovementComponent* MovementComponent;
/** For the explosion effect to show in the game world. */
UPROPERTY(EditDefaultsOnly, Category = GraphicsEffects)
UParticleSystem* ExplosionParticleSystem;
/** For the sound cue to play in the game world. */
UPROPERTY(EditDefaultsOnly, Category = SoundEffects)
USoundCue* ExplosionSoundCue;
UPROPERTY(EditDefaultsOnly, Category = Data)
FThrowableWeaponData GrenadeWeaponData;
UPROPERTY(EditDefaultsOnly, Category = Type)
class TSubclassOf<UDamageType> GrenadeDamageType;
UPROPERTY(EditDefaultsOnly, Category = VisualComponent)
UMaterialInterface* DefaultBodyMaterial;
/** To handle collision. */
UPROPERTY(EditDefaultsOnly, Category = Collision)
USphereComponent* CollisionComponent;
protected:
// Functions:
/** For when a component gets hit. */
UFUNCTION(BlueprintCallable, Category = Collision)
void OnComponentHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
/** For when this actor gets hit. */
UFUNCTION(BlueprintCallable, Category = Collision)
void ActorHit(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit);
/** For the detonation sequence */
void InitiateDetonationSequence(AActor* HitActor, UPrimitiveComponent* ComponentHit);
void DetermineTargetHit(AActor* TargetActor);
void HandleExplosion();
void ShowEffects(USceneComponent* TargetComponent);
void HandleDamage(USceneComponent* TargetComponent);
void HideComponent(USceneComponent* TargetComponent);
// Properties of this projectile:
/** The time in seconds, until the grenade explodes. */
float GrenadeLifespanAfterCollision;
/** The detonation sequence can only be initiated once. */
bool DetonationSequenceInitiated;
/** The time to see the explosion, before this actor is destroyed. */
float TimeToSeeExplosion;
/** The pawn that was hit. */
class AShooterCharacter* HitPawn;
/** To let the Player know when the grenade has been removed from play. */
ACharacter* PlayerCharacterReference;
// Constant values:
const FName ACTOR_HIT_METHOD_NAME = "ActorHit";
};
ProjPlasmaGrenade.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "ShooterGame.h"
#include "ProjPlasmaGrenade.h"
#include "ShooterCharacter.h"
#include "ShooterWeapon_Projectile.h"
#include "ShooterBot.h"
// Initialise:
AProjPlasmaGrenade::AProjPlasmaGrenade(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
// To stop tGC cleaning this up prematurly:
SetFlags(EObjectFlags::RF_MarkAsRootSet);
CollisionComponent = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("CollisionComponent"));
CollisionComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
CollisionComponent->InitSphereRadius(5.0f);
CollisionComponent->AlwaysLoadOnClient = true;
CollisionComponent->AlwaysLoadOnServer = true;
CollisionComponent->bTraceComplexOnMove = true;
CollisionComponent->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
CollisionComponent->SetNotifyRigidBodyCollision(true);
CollisionComponent->SetCollisionObjectType(COLLISION_PROJECTILE);
CollisionComponent->SetCollisionResponseToAllChannels(ECR_Ignore);
CollisionComponent->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Block);
CollisionComponent->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Block);
CollisionComponent->SetCollisionResponseToChannel(ECC_Pawn, ECR_Block);
CollisionComponent->OnComponentHit.AddDynamic(this, &AProjPlasmaGrenade::OnComponentHit);
SetRootComponent(CollisionComponent);
Body = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Body"));
Body->OverrideMaterials.Add(DefaultBodyMaterial);
Body->SetMaterial(0, DefaultBodyMaterial);
MovementComponent = ObjectInitializer.CreateDefaultSubobject<UProjectileMovementComponent>(this, TEXT("MovementComponent"));
MovementComponent->InitialSpeed = 3000.0f;
MovementComponent->MaxSpeed = 3000.0f;
MovementComponent->bShouldBounce = true;
MovementComponent->bBounceAngleAffectsFriction = true;
MovementComponent->Bounciness = 0.6f;
MovementComponent->Friction = 0.2f;
MovementComponent->BounceVelocityStopSimulatingThreshold = 5.0f;
MovementComponent->Velocity = FVector(3000.0f, 0.0f, 0.0f);
// When created, have the grenade be thrown away from the thrower:
MovementComponent->SetAutoActivate(true);
PlayerCharacterReference = UGameplayStatics::GetPlayerCharacter(this, 0);
}
void AProjPlasmaGrenade::OnComponentHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
if (!DetonationSequenceInitiated && GetWorld()->HasBegunPlay() && PlayerCharacterReference)
{
DetonationSequenceInitiated = true;
InitiateDetonationSequence(OtherActor, OtherComp);
}
}
void AProjPlasmaGrenade::ActorHit(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit)
{
if (!DetonationSequenceInitiated && GetWorld()->HasBegunPlay() && PlayerCharacterReference)
{
DetonationSequenceInitiated = true;
InitiateDetonationSequence(OtherActor, Hit.GetComponent());
}
}
void AProjPlasmaGrenade::InitiateDetonationSequence(AActor* HitActor, UPrimitiveComponent* ComponentHit)
{
DetermineTargetHit(HitActor);
if (HitPawn)
{
MovementComponent->StopMovementImmediately();
// Attach this to the component of the pawn that was hit:
AttachToComponent(ComponentHit, FAttachmentTransformRules(EAttachmentRule::KeepWorld,
EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, true));
Body->SetCollisionEnabled(ECollisionEnabled::Type::NoCollision);
}
FTimerHandle TimerHandle = FTimerHandle();
// Initiate the fuse countdown:
GetWorldTimerManager().SetTimer(TimerHandle, GrenadeLifespanAfterCollision, false);
HideComponent(Body);
HandleExplosion();
// Give Players time to see the explosion effect:
GetWorldTimerManager().SetTimer(TimerHandle, TimeToSeeExplosion, false);
Cast<AShooterCharacter>(PlayerCharacterReference)->GrenadeRemovedFromPlay();
Cast<AShooterWeapon_Projectile>(Cast<AShooterCharacter>(PlayerCharacterReference)->GetWeapon())->DestroyGrenade();
}
void AProjPlasmaGrenade::DetermineTargetHit(AActor* TargetActor)
{
HitPawn = Cast<AShooterBot>(TargetActor);
// A shooter bot was hit:
if (HitPawn) return;
HitPawn = Cast<AShooterCharacter>(TargetActor);
// The Player was hit:
if (HitPawn) return;
// Something else was hit:
HitPawn = nullptr;
}
void AProjPlasmaGrenade::HandleExplosion()
{
USceneComponent* TargetComponent;
if (HitPawn)
{
TargetComponent = HitPawn->GetMesh();
}
else
{
TargetComponent = Body;
HideComponent(TargetComponent);
}
ShowEffects(TargetComponent);
HandleDamage(TargetComponent);
}
void AProjPlasmaGrenade::ShowEffects(USceneComponent* TargetComponent)
{
// Make sure to keep the explosion's world scale:
UGameplayStatics::SpawnEmitterAttached(ExplosionParticleSystem, TargetComponent);
UGameplayStatics::SpawnSoundAttached(ExplosionSoundCue, TargetComponent);
}
void AProjPlasmaGrenade::HandleDamage(USceneComponent* TargetComponent)
{
TArray<AActor*> ActorsToIgnore;
UGameplayStatics::ApplyRadialDamageWithFalloff(this, GrenadeWeaponData.BaseDamage, GrenadeWeaponData.MinimumDamage,
TargetComponent->GetComponentLocation(), GrenadeWeaponData.BaseDamageRadius, GrenadeWeaponData.MaximumDamageRadius,
GrenadeWeaponData.DamageFalloff, GrenadeDamageType, ActorsToIgnore, this, PlayerCharacterReference->GetController(),
ECollisionChannel::ECC_Visibility);
}
void AProjPlasmaGrenade::HideComponent(USceneComponent* TargetComponent)
{
TargetComponent->SetVisibility(false);
}
Please let me know what is/may be causing this issue and also let me know if there is any additional information that would help in solving this issue, my thanks to you all.
[1]: /storage/temp/255137-playerpawn-blueprint-grenadespawnpoint.png
[2]: /storage/temp/255138-plasmagrenadeprojectile-blueprint-viewport.png
[3]: /storage/temp/255139-player-1st-person-holding-plasma-grenade.png
[4]: /storage/temp/255142-3rd-person-plasmagrenade-collider.png
[5]: /storage/temp/255143-3rd-person-plasmagrenade-body.pngc++transformfirst person templatecustom classprojectilesSun, 30 Sep 2018 15:18:06 GMTFioKronHow to change the speed of the projectile in First Person Template?https://answers.unrealengine.com/questions/832760/how-to-change-the-speed-of-the-projectile-in-first.html
I wanna make a FPS game , so i started using the First Person Template , i would like to ask , how to change the speed of the projectile when the starter gun is fired?fps shooter game samplefirst person templateSat, 29 Sep 2018 12:44:10 GMTCring3y_Usernam3Change walking speed in First Person template C++https://answers.unrealengine.com/questions/814178/change-walking-speed-in-first-person-template-c.html
So I have created a new C++ project using First Person template and now I just want to change walking speed. CharacterMovementComponent.cpp has these variables
MaxWalkSpeed = 600.0f;
WalkingSpeed = 165.f;
WalkingAcceleration = 500.f;
I tried changing these values to higher ones, but my character's speed is still the same... How can I change it?
It actually seems that whatever I change in CharacterMovementComponent.cpp it won't change anything in the game, even though I compile it correctly.
You can try creating that project yourself and check how to change it, because I didn't change anythingc++first person templateWed, 01 Aug 2018 21:32:50 GMTspvmsHow to get the First Person Bp working on my projecthttps://answers.unrealengine.com/questions/757705/how-to-get-the-first-person-bp-working-on-my-proje.html
Hello, let's go head first into the problem.
So I am making a game, specifically a first-person puzzle game. and I'm trying to use the First Person BP template in my pre-made project. and yes it is too late for me to just make a new project, I also tried migrating the main project over with no success.
Sorry if this was a little vague, thanks. - CyberpunkRevoltblueprintsblueprintfirst person templatefirst person blueprintTue, 13 Feb 2018 04:59:22 GMTCyberpunkRevolt[SOLVED] Line Trace points somewhere elsehttps://answers.unrealengine.com/questions/738820/line-trace-points-somewhere-else.html
Hi!
I am using LineTrace for the first time. My goal is to use it in a VR gaze-based teleport system. I followed some tutorial I found online and after some issues with the results decided to go to the basics by applying it to the FP-Character of the FPTemplate. I did what the turorial said as you can see in the picture here: ![alt text][1]
[1]: /storage/temp/224668-linetrace-bp.jpg
But when I hit on play and click the fire button the trace line is drawn pointing to the sky and backwards when I am aiming at at box. I think it has to do with the Get World Position node but I cant figure out how to solve it.
I know this is pretty basic stuff but I cant find the solution online.
Thanks!linetracefirst person templateThu, 21 Dec 2017 19:59:19 GMTRealRendersAble to Cook Project, but unable to package Projecthttps://answers.unrealengine.com/questions/666167/able-to-cook-project-but-unable-to-package-project.html
[link text][1]Hello!
I am working on a game that's using the FP C++ template. After making enough progress to want to do some early testing I attempted to build for Windows 32-bit. However, the packaging fails with the output log printing out "UNKNOWN ERROR". I thought of everything, deleting Intermediate, Saved and Binaries, running as Admin. I've even tried packaging a empty C++ project but it wouldn't complete.
Is it related to having projects on a separate drive?
[1]: /storage/temp/193040-package+error.txtc++packaging projectswindows 10first person templateThu, 03 Aug 2017 02:44:54 GMTSentryTheDefiantChanging pitch/roll max in PlayerCameraManager crashes UE4 every timehttps://answers.unrealengine.com/questions/677015/changing-pitchroll-max-in-playercameramanager-cras.html
I have a barely-modified version of the character from the base First Persion C++ template, which all works fine, but adding this block of code in the constructor causes crashes UE4 editor the moment I build it:
ATestProjectCharacter::ATestProjectCharacter()
{
APlayerCameraManager* CameraManager = UGameplayStatics::GetPlayerCameraManager(GetWorld(), 0);
CameraManager->ViewPitchMax = 360;
CameraManager->ViewRollMax = 360;
So, obviously I'm doing something wrong here, but it builds fine in VS, and it looks fine to me. Since this is a crash to desktop I don't have any feedback that could tell me what's gone wrong.
Anyone have any idea what's going on here?unreal engine 4c++crashfirst person templatecamera managerWed, 02 Aug 2017 01:11:42 GMTArdentStoic4.15 runs a blank project but crashes with FPShttps://answers.unrealengine.com/questions/662669/415-runs-a-blank-project-but-crashes-with-fps.html
Hi! I tried to open a new FPS template project with UE4.15 but it crashed. So I opened a blank project successfully and added the FPS Blueprints with Add New->Feature Pack and changed the GameMode to FirstPerson. But the project crashed when I clicked Play.
My laptop’s specs are - Dell Inspiron 15 3000 series, 4GB RAM (I’m aware this is low, but 4.16 works fine), Core i3 2.5 GHz, Windows 8.1 64-bit
Is it a RAM issue? Does 4.15 require a lot more RAM than 4.16, especially while running FPS?
Two logs I found in the Logs folder:
https://pastebin.com/nUj99eN8,
https://pastebin.com/BCnnBtaucrash4.15first person templateWed, 12 Jul 2017 04:53:09 GMTpynchonHow can I play a model created in a Blueprint firts person template like Blueprint flying template?https://answers.unrealengine.com/questions/669497/how-can-i-play-a-model-created-in-a-blueprint-firt.html
Hello, I create an entire "space city" model in a Blueprint firt person template, but I will like to "fly" into this model when I'll play it like in the flying template. I want to know if there is some way to change the "play" configuration or export or migrate the blueprints, lights, materials, and all the things?.exportmigratetemplatefirst person templateflying templateTue, 20 Jun 2017 23:46:50 GMTDefronDakCustom Network Player Start, spawns on some maps but not othershttps://answers.unrealengine.com/questions/594485/custom-network-player-start-spawns-on-some-maps-bu.html
We are using 4.15. We recently had to begin using a custom player start due to a bug between our single player tutorials (infinite death on spawn) and our multiplayer pvp game. The problem is, during the server travel to the selected map and mode, it works fine on all but 2 maps. It is only these maps specifically. We ended up having to remove them from the build entirely for our last milestone. I have copied our blueprints for both the gameplay and lobby game modes and player controllers to blueprintvue.com.
You can run the selected map in standalone just fine. However, if you try to run one of these two maps in standalone from the main menu (Lobby) it is stuck in an infinite loading screen. When looking at the logs, it can seem to spawn the FPC and is always trying to spawn it at the world 0, instead of the spawn point.
![PlayerSpawn Position][1]
[Lobby Player Controller][2]
[Lobby Game Mode][3]
[GamePlay Player Controller][4]
[GamePlay Game Mode][5]
[Game Log][6]
Player Spawn Points
![PlayerSpawnPoints_Front][7]
![PlayerSpawnProperties][8]/blueprint/s0657wu3/
[1]: /storage/temp/136169-screenshot00000.png
[2]: https://blueprintue.com/blueprint/_0du5bx1/
[3]: https://blueprintue.com/blueprint/6sv_vh8n/
[4]: https://blueprintue.com
[5]: https://blueprintue.com/blueprint/n07z25lp/
[6]: /storage/temp/136164-poravity.log
[7]: /storage/temp/136166-screenshot00002.png
[8]: /storage/temp/136167-playerspawnproperties.pngblueprintsnetworkingcollision detectionfirst person templateSat, 29 Apr 2017 19:31:56 GMTAngrySpartanFP_FirstPerson & TP_FirstPersonhttps://answers.unrealengine.com/questions/588725/fp-firstperson-tp-firstperson.html
I'm currently getting back into Unreal and doing some C++ programming. Starting with a blank C++ project and then importing the C++ first person feature pack it seems you get the you get the folder from templates "FP_FirstPerson", but if you start a project with the C++ first person feature pack, it seems you instead get "TP_FirstPerson".
There are significant differences between the two, FP_FirstPerson is missing any references to VR as far as I can see. Is there any reason why there are two different versions of the first person template content? I cannot see that this is the case for any of the other template content
The two folders can be seen [here][1]
[1]: https://github.com/EpicGames/UnrealEngine/tree/master/Templatesc++source codetemplatefirst person templatetemplate projectFri, 14 Apr 2017 02:43:08 GMTcmbUse functionalities from VR template in First Person template?https://answers.unrealengine.com/questions/588373/use-functionalities-from-vr-template-in-first-pers.html
Hello,
I have a level (based on the First Person template) which is working fine with my Oculus Rift (and gamepad).
I'd like to integrate the Oculus motion controllers. I found in my character blueprint how to enable motion controllers and also have the MotionController components, for both left and right side, already available in my FirstPersonCharacter BP. It works fine with the (VR) gun from the FP template. However, I'd like to use the hands and grab functionality from the VR template (and don't need the VR gun). How can I get these hands and grab animation in my First Person template instead of recreating everything from scratch? I thought about copying some parts of the VR template to my FP template or vice versa. I tried that but couldn't make it to work.
Any suggestions how I can do this please?
Thank you in advance.motion controllervr templatefirst person templateThu, 13 Apr 2017 11:58:39 GMTSuperfunkstarファーストパーソンキャラクターについてhttps://answers.unrealengine.com/questions/552165/%E3%83%95%E3%82%A1%E3%83%BC%E3%82%B9%E3%83%88%E3%83%8F%E3%83%BC%E3%82%BD%E3%83%B3%E3%82%AD%E3%83%A3%E3%83%A9%E3%82%AF%E3%82%BF%E3%83%BC%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6.html
ご確認くださりありがとうございます。いつもお世話になっております。
質問なのですが、FPSテンプレートでゲームを制作いる中、テンプレートのファーストパーソンキャラクターに足音を実装しようとしたところ、肝心なインプットAxis move forward イベントがフレームごとの更新をするという仕様のため、少し困っております。これはインプットアクションに変えたほうが良いのでしょうか？皆様のご意見、または解決方法を教えていただければ幸いです。
![alt text][1]
ちなみにですが。そのままサウンドをつけると、キーを入力していないにも関わらず、狂ったようにサウンドが連続再生されてしまいます。print textノードで試すと、helloが連続で入力されるので、当たり前といえば当たり前なのですが・・・。自分としては、キーを押している間だけ音が鳴るようにしたいので、現状はイベントノードを変えるかで悩んでいる状態です。返答をお待ちしております。
[1]: /storage/temp/123007-スクリーンショット+(25).pngunreal engine 4blueprintfirst person templateSat, 21 Jan 2017 07:05:19 GMT中村屋How to get projectile to spawn on muzzle socket?https://answers.unrealengine.com/questions/544999/how-to-get-projectile-to-spawn-on-muzzle-socket.html
I am trying to create an fps type game in VR and I have an issue with the projectile spawning when I am shooting. I am trying to have the projectile fire from the muzzle socket on the weapon but whenever I test out the game and pull the trigger to shoot the projectile continues to spawn from the middle of my body instead of from the muzzle of the gun. I don't know if the problem is because the gun is paired to one of the motion controllers or not. I am using the first person template blueprints so that the game can be played without VR as well.blueprintsvrprojectilesocketsfirst person templateThu, 05 Jan 2017 15:54:38 GMTmchsskillshow to create a variable category?https://answers.unrealengine.com/questions/524036/how-to-create-a-variable-category.html
my actual problem is that i wan't to make my projectile bounce, i've already posted a question here in answerhub and got no luck (https://answers.unrealengine.com/questions/520700/how-to-make-a-projectile-bounce.html)
i've tried to configure my projectile like the one from the first person sample project (in that project the projectile bounces), the only thing i couldn't reproduce is the "variable category", it's been set as "projectile" and this category doesn't exist in an empty project.
someone know how to create a variable category or a workaround to make my projectile bounce?
if it's not clear, this is what i'm talking about:
![alt text][1]
[1]: /storage/temp/115079-var+cat.pngblueprintprojectile movementfirst person templatevariable categoryWed, 16 Nov 2016 01:24:56 GMTveccherThird person shooter from first person templatehttps://answers.unrealengine.com/questions/519231/third-person-shooter-from-first-person-template.html
Hi,
I was wondering if it is possible to create a first person shooter template by adding the animation starter pack for the mannequin and animations?animationhelpweaponshooter gamefirst person templateFri, 04 Nov 2016 15:46:02 GMTKevinNisbetHow can I set my PlayerCharacter as my Default Player Start?https://answers.unrealengine.com/questions/503651/how-can-i-set-my-playercharacter-as-my-default-pla.html
So, I am creating this scene with the default FirstPersonCharacter and I deleted it because I (still) have an issue when creating a package, where my controls get all messed up, but only when I package my game, and not in the view port. How ever, I decided to delete my player, since I though that I broke it or something, and when I wanted to reimport the original one, every time I press play, I get double FirstPersonCharacters (Ill append a screenshot) and I want to have only one, and to start my game where my FirstPersonCharacter is placed, not where my Default player start is located.
Sorry for the long post, but I'm kind of losing my mind in here.
P.S: I just noticed my X-hair got messed up as well, I don't know what's going on!
[1]: /storage/temp/110276-error.pngblueprintsspawncrosshairfirst person templatedefault spawn pointMon, 10 Oct 2016 08:02:43 GMTShamysozaFPS template how to delay between shots RESOLVEDhttps://answers.unrealengine.com/questions/477317/fps-template-how-to-delay-between-shots.html
I just started a new first person template and I have my gun and everything, however I don't like how you can spam click bullets. I would like to know how to have a delay between shots. I would appreciate the help, thanks.blueprintsdelaygunfirst person templateMon, 29 Aug 2016 01:48:41 GMTCardboardmanDanC++ First/Third Person Template Server Player Can't Movehttps://answers.unrealengine.com/questions/468984/c-firstthird-person-template-server-player-cant-mo.html
If you create a new First/Third person project using the Blueprint templates and launch the game (without any changes) with 2 players, both the server and client players can move... However, if you create a First or Third person project using the C++ template and run it the same, the server player is unable to move while the client player can move just fine.
I'm new to the framework and was trying to use the C++ template as a reference to learn from... That said, I'm unable to figure out why it's not working and believe it to be a bug as it seems like it'd be rather silly if this were not a bug in a template that is otherwise identical to its Blueprint counterpart.
UE-31171c++bug reportfirst person templatethird person templatetemplate projectFri, 12 Aug 2016 17:35:19 GMTMheetuAdd Animations To First Person Characterhttps://answers.unrealengine.com/questions/455936/add-animations-to-first-person-character.html
Hi I am very new to UE4, I am trying to add an aiming Animation to The First Person Character
Things i've already done
-Export the fp idle anim to 3DS MAX
-Made and exported the aiming anim to UE4
I need help to setup the aiming animation in the first person template on to the arms in their.
i already made the Anim i just need help on the Blueprint side or what is the process for creating extra animations for the First Person Character.blueprintsanimationweaponfirst person templateaimingWed, 20 Jul 2016 23:35:59 GMTUser-909214441How to use Mixamo Rigged Character for First Personhttps://answers.unrealengine.com/questions/452842/how-to-use-mixamo-rigged-character-for-first-perso.html
Hi I am pretty new to UE4 and i saw some tutorials on rigging characters in Mixamo that is not compatible with the UE4 version i'm using. How do I implement the character rig and animations into UE4 1st Person Project?
Any info would help,
Thanksanimationcharacterriggingmixamofirst person templateFri, 15 Jul 2016 04:30:23 GMTUser-909214441Problem with animation using sk mobile mannequin.https://answers.unrealengine.com/questions/448964/problem-with-animation-using-sk-mobile-mannequin.html
So I am using the sk mobile mannequin witn the sk mannequin animations. I migrated the animations from a third person template to a first person template. When I play the animation my character arm and hand appear in the wrong position... I would like to know how could I fix it without changing the skeleton?
![alt text][1]
[1]: /storage/temp/97734-sk_mannequin_mobile_skeleton.jpganimationbonesskeletonfirst person templatethird person templateFri, 08 Jul 2016 20:16:29 GMTguivmcEPOC's gyro as a first person camerahttps://answers.unrealengine.com/questions/436825/epocs-gyro-as-a-first-person-camera.html
Hey, guys! I have a really big problem with my unreal game developing... This is because this project is for my final thesis which I present in 5 days!!
I use a first person template and everything works well except my gyroscope input. I am using the gyroscope on the EPOC headset and all I want to do is to set it as the camera controller... In fact, my computer recognises that gyroscope and I can even set it up as a mouse. Although, when I try to use it inside the engine it seems to not work at all... I have tried creating a new controller but it does not work as well... To make it simple, all I want to do is to replace the default x-y mouse movement that controls the camera and assign this function to the gyro...
Any help would be appreciated!! Thank you in advance!first person templategyroscopeThu, 16 Jun 2016 07:58:43 GMTanna2xHow do I create a config file for variables on character?https://answers.unrealengine.com/questions/430650/how-do-i-create-a-config-file-for-variables-on-cha.html
I am working in UE 4.7.6 and I have created a prototype game using the first person shooter (c++) template. I have been editing variables directly in the UE editor by writing UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Gameplay) before the given variables in the header file.
From what I have gathered, you can use UPROPERTY(Config) along with writing UCLASS(Config=Game) before the class declaration to create entry points in the config files, but I am not able to find the properties in the config files after doing so.configfirst person templateSat, 04 Jun 2016 16:54:10 GMTAkblablaUpdated project from 4.9 to 4.11, can't move Characterhttps://answers.unrealengine.com/questions/414155/updated-project-from-49-to-411-cant-move-character.html
I had a project that I was initially working with in 4.9, using the FirstPersonShooter template. This all worked fine. I've just updated the project to 4.11 and found that my character won't move any more. I've added some debug printouts which shows that the MoveForward method is being called, but nothing seems to happen. The character won't even fall due to gravity. The components of the character are all marked as movable.unreal engine 4c++first person templateMon, 02 May 2016 16:25:21 GMTZero One1st person pixelated character mesh and crosshairhttps://answers.unrealengine.com/questions/398720/1st-person-pixelated-character-mesh-and-crosshair.html
Hi
During PIE mode and builds for the First Person template, the character mesh is pixelated when moving or turning. Also, the crosshair looks funny all the times. See screenshot:
![alt text][1]
My settings are at maximum:
![alt text][2]
[1]: /storage/temp/85121-pixelated_mesh.png
[2]: /storage/temp/85122-scalability_settings.png
Specs:
Unreal 4.11
Windows 10 Home - OS Build 10586.164
NVIDIA GeForce GTX 960 - Driver version 364.724.11first person templatepixellatedSun, 03 Apr 2016 22:13:52 GMTAlmanzorCharacter aliasing when moving in first person templatehttps://answers.unrealengine.com/questions/386398/character-aliasing-when-moving-in-first-person-tem.html
I was working in a new BP first person template recently and noticed that there's some pretty significant aliasing around the edges of the first person models when moving/turning. It appears to be caused by motion blur affecting the first person mesh in odd ways.
Are there any solutions to this issue? It seems like there's some extra velocity being incorrectly applied to the edges of the objects?
![alt text][1]
![alt text][2]
[1]: /storage/temp/81332-alias.jpg
[2]: /storage/temp/81333-smooth.jpgrenderingmotion blurfirst person templatealiasingMon, 07 Mar 2016 23:31:27 GMT00k_Using mouse events in first person.https://answers.unrealengine.com/questions/382743/using-mouse-events-in-first-person.html
I want to make it so that when someone clicks a block it dissapears, but in the first person template with the cross in the center, it doesn't work.first personclick eventfirst person templateMon, 29 Feb 2016 02:53:09 GMTFlancosoft