I actually set something up like this last night, I have Archers firing at enemy’s (called MongerDaves ;p). I also used GetAllActorsOfClass here’s how how they acquire a target and then call the FireArrow event at a random enemy: https://i.imgur.com/7oT4I3P.jpg
It’s not such a simple question and needs to be broken down into lots of incremental steps. Those steps could vary from project to project, but here’s a rough outline.
-Who is my target?
-Where is my target?
-Can I see my target?
-Can I attack my target from where I currently am or do I need to move to where they are?
Now each of those needs to be broken down further. Alot of the logic here would be controlled via a Behaviour Tree, which would then fire information out to other Blueprints to handle things like animation.
I would recommend starting by going through Epic’s Behaviour Tree guide here:
Creating AI in UE4 means getting comfortable with alot of types of Blueprints and cross references each other. It would be better to get to know how to do that via those tutorials than to just rely on the community provided AI alone without understanding how it works.
As for the actual attack, what kind of attack are you talking about- ranged, melee, area etc? At the very least you would need to set up a health system, track that, change that and then kill a characte off when they die.
ahaa. that surely makes sence. i have watched newtons guide wich gave me some insight towards it.
but then again, as refered to at the top, i downloaded newtons AIproject template wich has those features. what i dont understand still lies in the GetAllActorsOfClass node. where if i put MyCharacter[the player character] the bot works perfectly, but if i change ‘‘MyCharacter’’ to a simple blueman copy named ‘‘Zombie’’ and then place ‘‘Zombie’’ in the bots path it just ignores it?
so there must be something i’ve missed since ‘‘zombie’’ doesnt invoke the same spot->run into range->attack as it doesnt with ‘‘MyCharacter’’
What i have done myself with great success:
1- Add a PawnSensingComponent to your bot pawn, this will give you a SeePawn event for blueprint, use that to set the target to attack.
2- Also, of course the victim should attack back, so add that the other AI attacks the one who attacks him, so set the enemy using the instigator from TakeDamage event.
This simple thing is working just fine for now in actual serious games, for an AI im developing for the game Heavy Gear Assault, i also use the pawnsensing component to get noise and target that.
Once i set the enemy on someone, that fires the whole behavior tree logic i have for combat stance.
And the problem is solved. everything solved itself when i recreated the ‘‘zombie’’ charactors setup with some of the pointers you guys gave me
never the less, a thousand thanks to you guys for your most helpfull advice and bonus idea’s to how it can be done with greater results!
AI is wierd to begin with, but the pieces are slowly falling together