Animations - Course 3.29
This commit is contained in:
parent
fe15fc91f5
commit
23d91e3931
|
@ -0,0 +1 @@
|
|||
|
|
@ -76,6 +76,8 @@ FOVScale=0.011110
|
|||
DoubleClickTime=0.200000
|
||||
+ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar)
|
||||
+ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Gamepad_FaceButton_Bottom)
|
||||
+ActionMappings=(ActionName="FireButton",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton)
|
||||
+ActionMappings=(ActionName="FireButton",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Gamepad_RightTrigger)
|
||||
+AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=W)
|
||||
+AxisMappings=(AxisName="MoveForward",Scale=-1.000000,Key=S)
|
||||
+AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=Gamepad_LeftY)
|
||||
|
|
BIN
Content/ParagonLtBelica/Characters/Heroes/Belica/Meshes/Belica_Skeleton.uasset (Stored with Git LFS)
BIN
Content/ParagonLtBelica/Characters/Heroes/Belica/Meshes/Belica_Skeleton.uasset (Stored with Git LFS)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Content/_Game/Character/Animations/Jog_Fwd_Start_Trimmed.uasset (Stored with Git LFS)
Normal file
BIN
Content/_Game/Character/Animations/Jog_Fwd_Start_Trimmed.uasset (Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/_Game/Character/Animations/Jog_Fwd_Stop_Trimmed.uasset (Stored with Git LFS)
Normal file
BIN
Content/_Game/Character/Animations/Jog_Fwd_Stop_Trimmed.uasset (Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/_Game/Character/Animations/Primary_Fire_Fast_Trimmed.uasset (Stored with Git LFS)
Normal file
BIN
Content/_Game/Character/Animations/Primary_Fire_Fast_Trimmed.uasset (Stored with Git LFS)
Normal file
Binary file not shown.
Binary file not shown.
BIN
Content/_Game/Character/ShooterCharacterBP.uasset (Stored with Git LFS)
BIN
Content/_Game/Character/ShooterCharacterBP.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/_Game/Maps/DefaultMap.umap (Stored with Git LFS)
BIN
Content/_Game/Maps/DefaultMap.umap (Stored with Git LFS)
Binary file not shown.
|
@ -0,0 +1,34 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "ShooterAnimInstance.h"
|
||||
|
||||
#include "ShooterCharacter.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
|
||||
void UShooterAnimInstance::UpdateAnimationProperties(float DeltaTime)
|
||||
{
|
||||
if (ShooterCharacter)
|
||||
ShooterCharacter = Cast<AShooterCharacter>(TryGetPawnOwner());
|
||||
|
||||
if (ShooterCharacter)
|
||||
{
|
||||
// Get the speed of the character from velocity
|
||||
FVector Velocity{ ShooterCharacter->GetVelocity() };
|
||||
Velocity.Z = 0;
|
||||
Speed = Velocity.Size();
|
||||
|
||||
// Is the character in the air
|
||||
bIsInAir = ShooterCharacter->GetCharacterMovement()->IsFalling();
|
||||
|
||||
// Is the character accelerating
|
||||
bIsAccelerating = ShooterCharacter->GetCharacterMovement()->GetCurrentAcceleration().Size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
void UShooterAnimInstance::NativeInitializeAnimation()
|
||||
{
|
||||
Super::NativeInitializeAnimation();
|
||||
|
||||
ShooterCharacter = Cast<AShooterCharacter>(TryGetPawnOwner());
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Animation/AnimInstance.h"
|
||||
#include "ShooterAnimInstance.generated.h"
|
||||
|
||||
class AShooterCharacter;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class SHOOTER_API UShooterAnimInstance : public UAnimInstance
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void UpdateAnimationProperties(float DeltaTime);
|
||||
|
||||
virtual void NativeInitializeAnimation() override;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Movement, meta = (AllowPrivateAccess = true))
|
||||
AShooterCharacter* ShooterCharacter;
|
||||
|
||||
/* The speed of the character */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Movement, meta = (AllowPrivateAccess = true))
|
||||
float Speed;
|
||||
|
||||
/* Whether or not the character is in the air */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Movement, meta = (AllowPrivateAccess = true))
|
||||
bool bIsInAir;
|
||||
|
||||
/* Whether or not the character is moving */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Movement, meta = (AllowPrivateAccess = true))
|
||||
bool bIsAccelerating;
|
||||
};
|
|
@ -4,7 +4,11 @@
|
|||
#include "ShooterCharacter.h"
|
||||
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Engine/SkeletalMeshSocket.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "Sound/SoundCue.h"
|
||||
|
||||
// Sets default values
|
||||
AShooterCharacter::AShooterCharacter() :
|
||||
|
@ -30,6 +34,16 @@ AShooterCharacter::AShooterCharacter() :
|
|||
|
||||
// Camera does not rotate relative to arm
|
||||
FollowCamera->bUsePawnControlRotation = false;
|
||||
|
||||
// Don't rotate when the controller does. Let the controller only affect the camera.
|
||||
bUseControllerRotationPitch = false;
|
||||
bUseControllerRotationYaw = false;
|
||||
bUseControllerRotationRoll = false;
|
||||
|
||||
GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input....
|
||||
GetCharacterMovement()->RotationRate = FRotator(0.f, 540.f, 0.f); // ... at this rotation rate
|
||||
GetCharacterMovement()->JumpZVelocity = 600.f;
|
||||
GetCharacterMovement()->AirControl = 0.2f;
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
|
@ -76,6 +90,33 @@ void AShooterCharacter::LookUpAtRate(float Rate)
|
|||
AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds()); // def/sec * sec/frame
|
||||
}
|
||||
|
||||
void AShooterCharacter::FireWeapon()
|
||||
{
|
||||
if (FireSound)
|
||||
{
|
||||
UGameplayStatics::PlaySound2D(this, FireSound);
|
||||
}
|
||||
|
||||
const USkeletalMeshSocket* BarrelSocket = GetMesh()->GetSocketByName("BarrelSocket");
|
||||
if (BarrelSocket)
|
||||
{
|
||||
const FTransform SocketTransform = BarrelSocket->GetSocketTransform(GetMesh());
|
||||
|
||||
if (MuzzleFlash)
|
||||
{
|
||||
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), MuzzleFlash, SocketTransform);
|
||||
}
|
||||
}
|
||||
|
||||
UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
|
||||
|
||||
if (AnimInstance && HipFireMontage)
|
||||
{
|
||||
AnimInstance->Montage_Play(HipFireMontage);
|
||||
AnimInstance->Montage_JumpToSection(FName("StartFire"));
|
||||
}
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void AShooterCharacter::Tick(float DeltaTime)
|
||||
{
|
||||
|
@ -98,5 +139,7 @@ void AShooterCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCo
|
|||
|
||||
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
|
||||
PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);
|
||||
|
||||
PlayerInputComponent->BindAction("FireButton", IE_Pressed, this, &AShooterCharacter::FireWeapon);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
class USpringArmComponent;
|
||||
class UCameraComponent;
|
||||
class USoundCue;
|
||||
class UParticleSystem;
|
||||
class UAnimMontage;
|
||||
|
||||
UCLASS()
|
||||
class SHOOTER_API AShooterCharacter : public ACharacter
|
||||
|
@ -40,6 +43,10 @@ protected:
|
|||
*/
|
||||
void LookUpAtRate(float Rate);
|
||||
|
||||
/**
|
||||
* Called when the Fire button is pressed
|
||||
*/
|
||||
void FireWeapon();
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
|
@ -63,6 +70,18 @@ private:
|
|||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = true))
|
||||
float BaseLookUpRate;
|
||||
|
||||
/* Randomized gunshot sound cue*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Combat, meta = (AllowPrivateAccess = true))
|
||||
USoundCue* FireSound;
|
||||
|
||||
/* Flash spawned at BarrelSocket */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Combat, meta = (AllowPrivateAccess = true))
|
||||
UParticleSystem* MuzzleFlash;
|
||||
|
||||
/* Montage for firing the weapon */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Combat, meta = (AllowPrivateAccess = true))
|
||||
UAnimMontage* HipFireMontage;
|
||||
|
||||
public:
|
||||
/* Returns CameraBoom SubObject */
|
||||
FORCEINLINE USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
|
||||
|
|
Loading…
Reference in New Issue