Enemy to attack random player pawn
I'm creating classical jrpg combat game (that is like Final Fantasy, chrono trigger and etc.) just for training but hitted wall recently.
I have to spawn player pawns cause I got 3 characters in combat but 6 characters in total what player can select witch ones is in combat (also can select locations from 6 different locations front row 3 and back row 3).
But if I got multiple enemies how I can make enemies to attack random target pawn? And how I can cast to that pawn to take damage?
Can be I'm thinking too hard and looking too far how to do it but I don't have got it to work no matter how hard I have tried.
Biggest problem for me is that I don't quite get casting to spawned pawn how it works.
I don't have found any tutorial for this kinda game so I need little help. Combat is mostly done otherwise and gonna make tutorial how to do it when I get it working.
Than you for reading my problem!
asked Jan 16 '15 at 04:07 PM in Blueprint Scripting
If you store references to the 3 enemies you can just store them in an array, then generate a random int between 0 and 2 and access that enemy in the array.
Or you could use a 'find all objects of class' node set to your enemy type.
OR if they're different enemies I would recommend that they all inherit from the same base class to make the above suggestion work.
there is another option, but I don't think it's as elegant in this case as inheritance - they could all contain a common blueprint interface to let you act on them in the same way. And this is actually how i'd recommend you implement damage. They all have an interface that allows the aggressor to access them and reduce their health.
You can even do things like find all characters that implement said interface.
Having said all this I think there may be some stuff already in UE4 specifically to deal with damage, i'v come across a few things while browsing the list of nodes. It may be worth a google first.
answered Jan 24 '15 at 12:14 PM
Asher S Einhorn
Follow this question
Once you sign in you will be able to subscribe for any updates here