Skip to content

Commit

Permalink
BT84 Tweaking Tank AI.cmproj
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Tristem committed Jul 23, 2016
1 parent d06b8d1 commit cc8b712
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 6 deletions.
Binary file not shown.
Binary file modified BattleTank/Content/Tank/Tank_BP.uasset
Binary file not shown.
Binary file added BattleTank/Content/TankAIController_BP.uasset
Binary file not shown.
Binary file modified BattleTank/Content/_Levels/BattleGround.umap
Binary file not shown.
5 changes: 4 additions & 1 deletion BattleTank/Source/BattleTank/Private/TankAIController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ void ATankAIController::Tick(float DeltaTime)
auto AimingComponent = ControlledTank->FindComponentByClass<UTankAimingComponent>();
AimingComponent->AimAt(PlayerTank->GetActorLocation());

AimingComponent->Fire(); // TODO limit firing rate
if (AimingComponent->GetFiringState() == EFiringState::Locked)
{
AimingComponent->Fire(); // TODO limit firing rate
}
}
9 changes: 8 additions & 1 deletion BattleTank/Source/BattleTank/Private/TankAimingComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ void UTankAimingComponent::TickComponent(float DeltaTime, enum ELevelTick TickTy
}
}

EFiringState UTankAimingComponent::GetFiringState() const
{
return FiringState;
}


bool UTankAimingComponent::IsBarrelMoving()
{
if (!ensure(Barrel)) { return false; }
Expand Down Expand Up @@ -115,4 +121,5 @@ void UTankAimingComponent::Fire()
Projectile->LaunchProjectile(LaunchSpeed);
LastFireTime = FPlatformTime::Seconds();
}
}
}

10 changes: 6 additions & 4 deletions BattleTank/Source/BattleTank/Public/TankAIController.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ UCLASS()
class BATTLETANK_API ATankAIController : public AAIController
{
GENERATED_BODY()


protected:
// How close can the AI tank get
UPROPERTY(EditDefaultsOnly, Category = "Setup")
float AcceptanceRadius = 8000;

private:
virtual void BeginPlay() override;

virtual void Tick(float DeltaSeconds) override;

// How close can the AI tank get
float AcceptanceRadius = 3000;
};
2 changes: 2 additions & 0 deletions BattleTank/Source/BattleTank/Public/TankAimingComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class BATTLETANK_API UTankAimingComponent : public UActorComponent
UFUNCTION(BlueprintCallable, Category = "Firing")
void Fire();

EFiringState GetFiringState() const;

protected:
UPROPERTY(BlueprintReadOnly, Category = "State")
EFiringState FiringState = EFiringState::Reloading;
Expand Down

0 comments on commit cc8b712

Please sign in to comment.