68 - Fire Montage
This commit is contained in:
parent
42f5e0135b
commit
99275f1b71
|
@ -78,6 +78,7 @@ DoubleClickTime=0.200000
|
|||
+ActionMappings=(ActionName="Equip",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=E)
|
||||
+ActionMappings=(ActionName="Crouch",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftControl)
|
||||
+ActionMappings=(ActionName="Aim",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=RightMouseButton)
|
||||
+ActionMappings=(ActionName="Fire",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton)
|
||||
+AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=W)
|
||||
+AxisMappings=(AxisName="MoveForward",Scale=-1.000000,Key=S)
|
||||
+AxisMappings=(AxisName="MoveRight",Scale=1.000000,Key=D)
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -62,6 +62,19 @@ void ABlasterCharacter::PostInitializeComponents()
|
|||
}
|
||||
}
|
||||
|
||||
void ABlasterCharacter::PlayFireMontage(bool bAiming)
|
||||
{
|
||||
if (Combat == nullptr || Combat->EquippedWeapon == nullptr) return;
|
||||
|
||||
UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
|
||||
if (AnimInstance && FireWeaponMontage)
|
||||
{
|
||||
AnimInstance->Montage_Play(FireWeaponMontage);
|
||||
FName SectionName = bAiming ? FName("RifleADS") : FName("RifleHip");
|
||||
AnimInstance->Montage_JumpToSection(SectionName);
|
||||
}
|
||||
}
|
||||
|
||||
void ABlasterCharacter::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
@ -83,6 +96,8 @@ void ABlasterCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCo
|
|||
PlayerInputComponent->BindAction("Crouch", IE_Pressed, this, &ABlasterCharacter::CrouchButtonPressed);
|
||||
PlayerInputComponent->BindAction("Aim", IE_Pressed, this, &ABlasterCharacter::AimButtonPressed);
|
||||
PlayerInputComponent->BindAction("Aim", IE_Released, this, &ABlasterCharacter::AimButtonReleased);
|
||||
PlayerInputComponent->BindAction("Fire", IE_Pressed, this, &ABlasterCharacter::FireButtonPressed);
|
||||
PlayerInputComponent->BindAction("Fire", IE_Released, this, &ABlasterCharacter::FireButtonReleased);
|
||||
|
||||
PlayerInputComponent->BindAxis("MoveForward", this, &ABlasterCharacter::MoveForward);
|
||||
PlayerInputComponent->BindAxis("MoveRight", this, &ABlasterCharacter::MoveRight);
|
||||
|
@ -218,6 +233,22 @@ void ABlasterCharacter::Jump()
|
|||
}
|
||||
}
|
||||
|
||||
void ABlasterCharacter::FireButtonPressed()
|
||||
{
|
||||
if (Combat)
|
||||
{
|
||||
Combat->FireButtonPressed(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ABlasterCharacter::FireButtonReleased()
|
||||
{
|
||||
if (Combat)
|
||||
{
|
||||
Combat->FireButtonPressed(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ABlasterCharacter::ServerEquipButtonPressed_Implementation()
|
||||
{
|
||||
EquipButtonPressed();
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
||||
virtual void PostInitializeComponents() override;
|
||||
void PlayFireMontage(bool bAiming);
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
@ -32,6 +33,8 @@ protected:
|
|||
void AimButtonReleased();
|
||||
void AimOffset(float DeltaTime);
|
||||
virtual void Jump() override;
|
||||
void FireButtonPressed();
|
||||
void FireButtonReleased();
|
||||
|
||||
private:
|
||||
UPROPERTY(VisibleAnywhere, Category="Camera")
|
||||
|
@ -62,6 +65,9 @@ private:
|
|||
|
||||
ETurningInPlace TurningInPlace;
|
||||
void TurnInPlace(float DeltaTime);
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = Combat)
|
||||
class UAnimMontage* FireWeaponMontage;
|
||||
public:
|
||||
void SetOverlappingWeapon(AWeapon* Weapon);
|
||||
bool IsWeaponEquipped();
|
||||
|
|
|
@ -55,6 +55,15 @@ void UCombatComponent::OnRep_EquippedWeapon()
|
|||
}
|
||||
}
|
||||
|
||||
void UCombatComponent::FireButtonPressed(bool bPressed)
|
||||
{
|
||||
bFireButtonPressed = bPressed;
|
||||
if (Character && bFireButtonPressed)
|
||||
{
|
||||
Character->PlayFireMontage(bAiming);
|
||||
}
|
||||
}
|
||||
|
||||
void UCombatComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
|
|
@ -31,6 +31,8 @@ protected:
|
|||
UFUNCTION()
|
||||
void OnRep_EquippedWeapon();
|
||||
|
||||
void FireButtonPressed(bool bPressed);
|
||||
|
||||
private:
|
||||
class ABlasterCharacter* Character;
|
||||
|
||||
|
@ -45,4 +47,6 @@ private:
|
|||
|
||||
UPROPERTY(EditAnywhere)
|
||||
float AimWalkSpeed;
|
||||
|
||||
bool bFireButtonPressed;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue