Is there a function that instead of "Is in Attack Range Of Player"node?

I’m learning UE4(and C++) through the book “Learning.C++.by.Creating.Games.with.UE4.2015”.
The book is about UE4.6(or someother version,I’m not sure). My version is 4.10.
So there are some compatible promblem.

  1. And one of the problem is there have no node “Is in Attack Range Of Player”(appears in chapter 11,above "Code to swing the sword ").So the question is Which function replaced it ?
  2. AND,Below the "Code to swing the sword " ,there are a function definition :

void AMonster:: SwordSwung()//A function that will be invoked in a blueprints node

{

if(MeleeWeapon) //MeleeWeapon is definition in AMonster as follows"AActor* MeleeWeapon;"

  {  

     MeleeWeapon->Swing();//Here is the problem. VS return an error point that "class 'AActor'  

                                          //has no member Swing()".   

 }  

}


I’m search for the solution in many place. But still don’t get the point. This really made me depressed.
Hope this time will help!
Thanks for everyone for reading here.

Thats a expected error.

You have a AActor pointer that should be your Sword. Problems is AActor does not know how to Swing a Sword because the Code inside AActor does not have a Swing() Function.

You can create a class that inherits from AActor say AWeapon and than you can teach this class how to Swing() and istead of pointing to a AActor* you would use AWeapon* (This can point to any weapon or children of AWeapon)

But if you want to use a AActor* and you know you refference a AWeapon Object in there you first have to check if it really is AWeapon or something completly else that inherits from AActor. The only thing your Code know right now is that it can do what a AActor can do.

Here is how you would check if its pointing to a specific Child Type its called Casting.

AWeapon* TheRealClass= Cast<AWeapon>(MeleeWeapon); //MeleeWeapon is a AActor* we try to Cast it to a AWeapon or ABow or ASomethingElse
if(TheRealClass != nullptr)
{
// The Cast was succesful MeleeWeapon is a AWeapon Type (or something that inherts from AWeapon) and now your Code knows that you can Call TheRealClass->Swing() we can safly call all the things a AWeapon has.
}
else
{
// Cast failed its a AActor but its not a AWeapon! Dont try to access TheRealClass here.
}

You can find this function in Monster.h file from the ePub files for this book (visit PacktPub.com).

inline bool isInAttackRange(float d)
{
	return d < AttackRangeSphere->GetScaledSphereRadius();
}