Get AI character location C++
Hi, Note I am relatively low skilled in C++. I am trying to:
As far as I know, TArray and TActorIterator should do the job, but I can't seem to be able to use them properly. I was able to produce csv files. So the main issue is with the first two points. A detailed answer would be very much appreciated.
Thanks in advance.
asked Jan 23 '19 at 01:22 PM in C++ Programming
This would be one way to achieve what you want:
but it would be the most 'hacky' way, as the use of GetAllActorsOfClass() is even mentioned in its comment that is very expensive and mustn't be used every frame (what my example does), but if you trigger this method at a specific point in your game (e.g. when every ai character was spawned) then you can cache the resulting array from it and iterate through the cached array.
If it is not deterministic for you to say when "every" AICharacter is spawned then I would recommend to add the AICharacters to a cached array, at the moment when they're spawned and removed when they're destroyed (but the information still would need to be persisted). But if you're a beginner then this might be a much more complex approach and not even needed. I hope my answers helped.
Follow this question
Once you sign in you will be able to subscribe for any updates here