I was wondering what is the best way to build my AI.
Right now I got my BasicEnemy which comes from ACharacter where I got multiple variables such as health,damage and so on.
Now I want to build multiple other AIChars from this BasicEnemy for example BookEnemy, im doing the same for the controller for the AI where I got a BasicController and so on.
Now I added a service in my behaviour tree that calls a certain function in my PegControllerLight controller that has to reduce the health from the player by the damage of BookEnemy.
It looks like GetPawn() does not return AAI_PegEnemyLight. You should use Cast to check this, or you can get basic pawn class (if I correctly understand your Damage variable is in BasicEnemy class)
BasicEnemy* pEnemy = Cast<BasicEnemy>(GetPawn());
If (pEnemy)
{
// to do smth
pEnemy ->Damage = ...
}
yes its correct that my Damage variable is being made in my BasicEnemy, but I overwrite it in AAI_PegEnemyLight constructor. And that is the variable that I need to get…
When I use
AAI_BasicEnemy* pEnemy = Cast(GetPawn());
I indeed can cast it to an BasicEnemy and read the variables.
How come I cant use
AAI_PegEnemyLight* AiChar = Cast(GetPawn());
To receive the variables I set in the constructor if my AI_PegEnemyLight
My first guess is that somewhere in your basic class, like in begin play for example, you are writing over the damage in your derived class’s constructor. Is the cast for the derived class not working or are the variables not what you want them to be?