Guest User

Character.cpp

a guest
Oct 16th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2.  
  3. #pragma once
  4. #include "ZombieCharacter.h"
  5. #include "ZombieController.h"
  6. #include "Engine.h"
  7.  
  8. // Sets default values
  9. AZombieCharacter::AZombieCharacter()
  10. {
  11.     // Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
  12.     PrimaryActorTick.bCanEverTick = true;
  13.  
  14. }
  15.  
  16. // Called when the game starts or when spawned
  17. void AZombieCharacter::BeginPlay()
  18. {
  19.     Super::BeginPlay();
  20.  
  21.     GetWorld()->GetTimerManager().SetTimer(changeLocationTimerHandle, this, &AZombieCharacter::ChangeRandomLocation, 5.f, true, 0.f);
  22. }
  23.  
  24. // Called every frame
  25. void AZombieCharacter::Tick(float DeltaTime)
  26. {
  27.     Super::Tick(DeltaTime);
  28.  
  29. }
  30.  
  31. // Called to bind functionality to input
  32. void AZombieCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
  33. {
  34.     Super::SetupPlayerInputComponent(PlayerInputComponent);
  35. }
  36.  
  37. void AZombieCharacter::ChangeRandomLocation()
  38. {
  39.     if (!controller)
  40.     {
  41.         GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Red, TEXT("Could not get the AI controller"));
  42.         return;
  43.     }
  44.     controller->ChangeRandomLocation((APawn*)this, GetWorld());
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment