Monday 20 February 2017

Array


Basics
As well as loops and instantiation, arrays were going to be shown through creating snow in my first prototype. With this final concept needing to be shown I researched how to achieve this in my second prototype. I could have made an inventory for my character to store their weapons but I decided to display arrays through patrolling enemies. As there will be a number of target points the enemy has to move to it counts as a collection of data a variable. 


HowI watched a tutorial called 'Unreal Engine 4 - AI Improve Patrol' (Titanic Games, 2016). I will be able to show another form of coding AI compared to the first prototype. The image below shows the whole blueprint class I made for this enemy. I will break down what this all does.

First I started a custom event called 'PatrolToPoint'. I referenced this custom event to be activated when the level begins (Event BeginPlay). Next, I created my array variable called 'PatrolPoints' which is a target point data type. In this variable, there are all the target points the enemy will to. Next I another variable called 'Patrol Index' which shows the index of the target points within the array. I linked the two variable to get to get the index of the targets in the array. The 'AiMoveTo' node tells the enemy where to move to. So linking get to target actor this tells the AI to move to the targets within the arrays. Finally, the pawn is 'Self' the enemy class. 



Next, I needed to make a conditional statement. While there might make been a way of use an 'if else' statement I felt that a 'true or false' statement would get faster and easier to use. I made the condition that when the length of the array is meet then the condition is true. 


When the condition is true reset index back to 0 and begins 'Patrol to Point' again. If false then move to next target. 



Testing

After completing this blueprint class I decided to test the class. The basic function of this class worked. The enemy moved constantly moved from point to point without stopping. I decided to add to the function of this enemy. I added when sensing player, follower player. When player collides with the enemy, player restarts the level. 


I could have migrated the enemy class from TimmyAdventures project like I did for the 'PressE' class but I decided to try an alternative way of getting the enemy to follow the player. I tried out two new nodes from the library of codes. Testing this new method and I discover that it works much as well as the 'AI Move To' node. 
Next, I tried out using knowledge from prototype 1 for this function to restart the level. I remembered the node 'Get all Actors of class' from the open level blueprint in 'Outside_level'. I created a custom event within my First Person Character class and referenced it in Enemy. So when player overlaps with enemy box, get 'Kill Player' custom event from 'First Person Character' and activate the custom event. 
In the end, I cut both of these extra functions as they were causing issues while playing the level. Looking back now I think I can see the issue, the custom event must have been activated by something within the first person character class as well as the enemy overlap. I'm not sure what it was but if I had more time I'm sure I could have fixed the issue.




WhyIf the pawn sensing and kill player blueprints work, this would have displayed horror through gameplay. The gameplay idea was to have the player sneak through this area trying to avoid enemy sight. This was to bring tension to the level and you need tension to make a horror game.  While I wasn't able to try tension to this function have been able to display a horror visual style by making undead models for enemies. Another reason why I did this was to tick off arrays as another programming concept I was able to use across my two prototypes.



Industry expectations


Usability in games like my AI in my first prototype I have been able to show a basic use of AI. While both are limited they do show functions AI could have. This AI doesn't have enough functions or complexity to be usable. If I was able to get those extra functions this would be the usable code I could use in other projects.



Ready made libraries - I was able to use 'AI Move To' node from the character class. Which was made for characters specifically? The other nodes you can get from the other classes so I didn't use that much from the library for this class. 


Re-usability -This blueprint is independent of any other class. While in the game it goes through a constant state of moving from point to point. I could change the static mesh and use this in another project if I needed this function. As I have already copied this class to create the other enemies in the level. I can confirm that this is easy to adjust and is re-usable. 


Time management


In such a short amount of time, I have been able to complete all but one of the tasks set for prototype two. The reason why is due to the fact that I did a lot of these tasks in prototype one. So I was able to use my knowledge learnt from creating prototype one to create prototype two. while there is still one task left, I feel that I was able to display this in my first prototype, so I don't need to complete it in this prototype.  With 10 days to go, I am rather happy with my progress as I'm beyond what I expected to be at this time.


Bibliography

Titanic Games, (2016). Unreal Engine 4 - AI Improved Patrol. [online] YouTube. Available at: https://www.youtube.com/watch?v=0gU5StGSq_o [Accessed 18 Feb. 2017].

No comments:

Post a Comment