49 - Aiming
This commit is contained in:
parent
add3b474be
commit
a731448ee1
|
@ -77,6 +77,7 @@ DoubleClickTime=0.200000
|
|||
+ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar)
|
||||
+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)
|
||||
+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.
|
@ -32,4 +32,5 @@ void UBlasterAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
|
|||
bIsAccelerating = BlasterCharacter->GetCharacterMovement()->GetCurrentAcceleration().Size() > 0.f;
|
||||
bWeaponEquipped = BlasterCharacter->IsWeaponEquipped();
|
||||
bIsCrouched = BlasterCharacter->bIsCrouched;
|
||||
bAiming = BlasterCharacter->IsAiming();
|
||||
}
|
||||
|
|
|
@ -38,4 +38,7 @@ private:
|
|||
|
||||
UPROPERTY(BlueprintReadOnly, Category="Movement", meta=(AllowPrivateAccess = "true"))
|
||||
bool bIsCrouched;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="Movement", meta=(AllowPrivateAccess = "true"))
|
||||
bool bAiming;
|
||||
};
|
||||
|
|
|
@ -71,6 +71,8 @@ void ABlasterCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCo
|
|||
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
|
||||
PlayerInputComponent->BindAction("Equip", IE_Pressed, this, &ABlasterCharacter::EquipButtonPressed);
|
||||
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->BindAxis("MoveForward", this, &ABlasterCharacter::MoveForward);
|
||||
PlayerInputComponent->BindAxis("MoveRight", this, &ABlasterCharacter::MoveRight);
|
||||
|
@ -137,6 +139,22 @@ void ABlasterCharacter::CrouchButtonPressed()
|
|||
}
|
||||
}
|
||||
|
||||
void ABlasterCharacter::AimButtonPressed()
|
||||
{
|
||||
if (Combat)
|
||||
{
|
||||
Combat->SetAiming(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ABlasterCharacter::AimButtonReleased()
|
||||
{
|
||||
if (Combat)
|
||||
{
|
||||
Combat->SetAiming(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ABlasterCharacter::ServerEquipButtonPressed_Implementation()
|
||||
{
|
||||
EquipButtonPressed();
|
||||
|
@ -164,6 +182,11 @@ bool ABlasterCharacter::IsWeaponEquipped()
|
|||
return Combat && Combat->EquippedWeapon;
|
||||
}
|
||||
|
||||
bool ABlasterCharacter::IsAiming()
|
||||
{
|
||||
return Combat && Combat->bAiming;
|
||||
}
|
||||
|
||||
void ABlasterCharacter::OnRep_OverlappingWeapon(AWeapon* LastWeapon)
|
||||
{
|
||||
if (OverlappingWeapon)
|
||||
|
|
|
@ -27,6 +27,8 @@ protected:
|
|||
void LookUp(float Value);
|
||||
void EquipButtonPressed();
|
||||
void CrouchButtonPressed();
|
||||
void AimButtonPressed();
|
||||
void AimButtonReleased();
|
||||
|
||||
private:
|
||||
UPROPERTY(VisibleAnywhere, Category="Camera")
|
||||
|
@ -52,4 +54,5 @@ private:
|
|||
public:
|
||||
void SetOverlappingWeapon(AWeapon* Weapon);
|
||||
bool IsWeaponEquipped();
|
||||
bool IsAiming();
|
||||
};
|
||||
|
|
|
@ -18,6 +18,17 @@ void UCombatComponent::BeginPlay()
|
|||
Super::BeginPlay();
|
||||
}
|
||||
|
||||
void UCombatComponent::SetAiming(bool bIsAiming)
|
||||
{
|
||||
bAiming = bIsAiming;
|
||||
ServerSetAiming(bIsAiming);
|
||||
}
|
||||
|
||||
void UCombatComponent::ServerSetAiming_Implementation(bool bIsAiming)
|
||||
{
|
||||
bAiming = bIsAiming;
|
||||
}
|
||||
|
||||
void UCombatComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
@ -29,6 +40,7 @@ void UCombatComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& Out
|
|||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||
|
||||
DOREPLIFETIME(UCombatComponent, EquippedWeapon);
|
||||
DOREPLIFETIME(UCombatComponent, bAiming);
|
||||
}
|
||||
|
||||
void UCombatComponent::EquipWeapon(AWeapon* WeaponToEquip)
|
||||
|
|
|
@ -23,10 +23,17 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
void SetAiming(bool bIsAiming);
|
||||
|
||||
UFUNCTION(Server, Reliable)
|
||||
void ServerSetAiming(bool bIsAiming);
|
||||
|
||||
private:
|
||||
class ABlasterCharacter* Character;
|
||||
|
||||
UPROPERTY(Replicated)
|
||||
class AWeapon* EquippedWeapon;
|
||||
|
||||
UPROPERTY(Replicated)
|
||||
bool bAiming;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue