Work Experience Journal - Day 21
- Feb 5, 2019
- 2 min read
I managed to stop the simple test AI from choosing the locator that i'm next to and from choosing the same spot twice by using arrays. I did this by adding all the locators into an array and making a copy. After the AI has chosen a locator, it removes that locator from the array so it can't be chosen and saves a reference to the locator. Then it moves again it saves a reference to the next locator and refreshes the array to add all the locators back. Afterwards, when it moves again it compares the next locator with the one it is on and if it is not equal it moves. If it is equal then it finds a new a new locator.
If the player was to stand near a locator, it set the locator to claimed so the AI can't claim it. The AI checks to see if it is claimed every time it moves. If claimed it finds a new locator.
From this, I learnt a lot more about arrays and how they can be used. This opens up a lot of potential in the future when creating AI similar to this or when needing to get an actor reference from an array.
Helpful Links
https://www.youtube.com/watch?v=3A5PjUycPI4
https://api.unrealengine.com/INT/Videos/PLZlv_N0_O1ga2b_ZaJoaR5dLHOFw4-MMl/bGtQmuav748/index.html
https://www.youtube.com/watch?v=7EoONaD8vE4
https://api.unrealengine.com/INT/Videos/PLZlv_N0_O1ga2b_ZaJoaR5dLHOFw4-MMl/5nLqEW6YXPY/index.html
Harvard References
Anon (n.d.) 05 - Enum Variables. Available from: https://api.unrealengine.com/INT/Videos/PLZlv_N0_O1ga2b_ZaJoaR5dLHOFw4-MMl/5nLqEW6YXPY/index.html [Accessed 5 February 2019].
Anon (n.d.) 08 - Arrays. Available from: https://api.unrealengine.com/INT/Videos/PLZlv_N0_O1ga2b_ZaJoaR5dLHOFw4-MMl/bGtQmuav748/index.html [Accessed 5 February 2019].
Wadstein, M. (2016) WTF Is? Array: Remove / Remove Index Node in Unreal Engine 4 ( UE4 ). [online]. Available from: https://www.youtube.com/watch?v=7EoONaD8vE4 [Accessed 5 February 2019].
Wadstein, M. (2015) WTF Is? The For Each Loop Node. [online]. Available from: https://www.youtube.com/watch?v=3A5PjUycPI4 [Accessed 5 February 2019].
Comments