Different code but same result i think is there any problem?

void ATankAiController::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (GetPlayerTank())
{
FVector HitLocation = GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorLocation();

	GetControlledTank()->AimAt(HitLocation);
	//GetControlledTank()->AimAt(HitLocation);
}

}

That looks fine and saves on the cast. For future reference to get code formatting use this:

```cpp
code here
```

void ATankAiController::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
    if (GetPlayerTank())
    {
        FVector HitLocation = GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorLocation();
        GetControlledTank()->AimAt(HitLocation);
        //GetControlledTank()->AimAt(HitLocation);
    }
}

Wow! that is a little long, I came up with similar but i think cleaner code, Remember that GetPlayerTank() already returns the PlayerTank so all we need to do is get the ActorLocation and pass that into the aimAt(); I am just guessing that the next thing will be to make it turn towards and movetowards the player whilst firing all the time.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Due to inactivity this topic will close in 7 days.
Please either contact a moderator for this to be unlocked or start a new thread.

Thank-you

Privacy & Terms