151 - Grenades in Multiplayer
This commit is contained in:
parent
5c1967bdaa
commit
899f058596
|
@ -315,10 +315,18 @@ void UCombatComponent::ThrowGrenadeFinished()
|
||||||
void UCombatComponent::LaunchGrenade()
|
void UCombatComponent::LaunchGrenade()
|
||||||
{
|
{
|
||||||
ShowAttachedGrenade(false);
|
ShowAttachedGrenade(false);
|
||||||
if (Character && Character->HasAuthority() && GrenadeClass && Character->GetAttachedGrenade())
|
if (Character && Character->IsLocallyControlled())
|
||||||
|
{
|
||||||
|
ServerLaunchGrenade(HitTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UCombatComponent::ServerLaunchGrenade_Implementation(const FVector_NetQuantize& Target)
|
||||||
|
{
|
||||||
|
if (Character && GrenadeClass && Character->GetAttachedGrenade())
|
||||||
{
|
{
|
||||||
const FVector StartingLocation = Character->GetAttachedGrenade()->GetComponentLocation();
|
const FVector StartingLocation = Character->GetAttachedGrenade()->GetComponentLocation();
|
||||||
FVector ToTarget = HitTarget - StartingLocation;
|
FVector ToTarget = Target - StartingLocation;
|
||||||
FActorSpawnParameters SpawnParams;
|
FActorSpawnParameters SpawnParams;
|
||||||
SpawnParams.Owner = Character;
|
SpawnParams.Owner = Character;
|
||||||
SpawnParams.Instigator = Character;
|
SpawnParams.Instigator = Character;
|
||||||
|
|
|
@ -40,6 +40,9 @@ public:
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void LaunchGrenade();
|
void LaunchGrenade();
|
||||||
|
|
||||||
|
UFUNCTION(Server, Reliable)
|
||||||
|
void ServerLaunchGrenade(const FVector_NetQuantize& Target);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
void SetAiming(bool bIsAiming);
|
void SetAiming(bool bIsAiming);
|
||||||
|
|
Loading…
Reference in New Issue