Hello community!
Please help me understand my mistake.
I have 2 classes - MainCharacter (ACharacter) and EnemyCharacter (ACharacter)
From EnemyCharacter i can cast to MainCharacter :
Is there a specific error you are getting? Is it in the IDE (Visual Studio, X Code etc.) or is it during runtime? Do you have an output of the specific error? Is the AEnemyCharacter object controlled by another player either locally or in a networked game?
Apple inherited from Fruit and Banana inherited from Fruit. Apple can be cast to Fruit, since it is initially a Fruit. Same for Banana. But an Apple can’t become a Banana, or Banana can’t become an Apple. This is the same for your EnemyCharacter and MainCharacter.
I’ll assume you have a main character and enemy character at the same time controlled by other players. You’ll need to get the player with the right index. Now it is always getting the player at index 0, which is (i assume) a maincharacter. Enemycharacter is probably at index 1.
Yes,he present.I wanted to make control through the AI controller, but I have not yet started this.I now do not know what to do when I create a new controller class, how to access the Enemychar class - cast failed(
But right now it is not beung possesed by a player? It just stands there? Then GetPlayerCharacter wont work. You could try with getactorsfromclass function to get all enemychar in the level in an array. Then get the health from there. There is probably another more efficient way but its too early for me to think xd