Wednesday 4 January 2017

Collision detection and handling

Basics - As I have designed my prototype to include a lot of trigger events and to move the game along, I felt it was important to understand the types of collision within the unreal engine. In reflection on collision detection and handling is a simple yet important part of game programming.  For example, I plan to use collision detection when the player collides with the icy water and the collision handling will be on collision kill character. 

What - Reading up on Collision detection and handling (unrealengine,2014). Helped me understand how I use these concepts in my own prototype. I learnt of the different types like trigger box - which allows a function to occur when overlap happens, blocking volume - which is an invisible box that has collision, so you can't walk through it (i.e. an invisible wall used it a lot of games), nav mesh bounds - this means that the enemy will be able to navigate only through bounds of this box, and Kill Z Volume - once the character begins to overlap with is box, character is destroyed. 


Method - The method I want demonstrate collision detection and handling will be using a number of different types of collisions boxes like   Kill Z volumes for the water, blocking volumes to stop the character from escaping the level, and trigger boxes to display instructions.


How-  I used collision detection and handling for instructions for what key to press the switch.


The basic function I want is: when the character begins to overlap with trigger box activate toggle visibility on. When the end of overlap toggle visibility off. When creating this function I found it a struggle to get it to function correctly. I used a tutorial called 'Unreal Engine 4 Tutorial - Interactable Button' (Tesla Dev, 2014to understand a way this function could be done. So I followed this tutorial's instructions only to find when testing it didn't work. 

After testing the function a number of times with no results I decided to use my initiative and create my own blueprint. Casting to third- person character so the blueprint knows what needs to overlap the box to trigger the event. I used a conditional statement like in the tutorial blueprint and my self-made variable called 'InTrigger' which makes the text visible and invisible. I used an 'InTrigger' set node for my begin overlap, I ticked the set node to registered in the branch as true. For the end overlap, I didn't tick the set variable which registered false in the branch node. In the end, I only added 'cast to third person character' and this blueprint didn't work. I decided to start again.


With the knowledge I gained from the tutorial and from trying it out myself I was able to create a blueprint that worked. I used Cast to third person Character from my own blueprint and the text render variable for the tutorial but the rest I found in the actor blueprint library. I used 'set hidden in game' node to hide the text when the player isn't colliding with the trigger box. I made sure that when the level begins the text will be hidden and only when the character overlaps with the trigger, the text becomes visible. This final version of the blueprint worked. 



Where - This trigger box will be placed over the switch so when the player gets near the switch the text will appear and tell them what to do.

Why - I purposely designed the beginning to give no instructions on how to play, I started the player off in the same environment to test the controls. With subtractive design I felt like giving instructions wasn't necessary. Fumito Ueda's (who popularised subtractive design) game 'Ico' didn't give any instructions but in a safe environment. 


 Next, I designed the jumping platform section to get the player used to jumping. I'm trying to design the level with flow channel in mind. When the player gets near the switch I decided it was too far of a jump to conclusions to expect the player to know what key to press. So I wanted the instructions to be clear. When you're near the switch text will appear saying 'Press E' so the player presses 'E' out of instinct. If I added to this game the next time the player sees a switch I won't need to give these instructions.


Industry expectations - 


After copying a blueprint from a tutorial, then changing it to make it work better and finally making my own blueprint. I think I have used industry practice in testing and refining a code for its efficiency. Using a concept from a tutorial and altering it to suit my purpose and make it simpler. Instead of anything overlapping with the trigger box, I have cast it to the third person character. 


Ready made libraries - When creating my own blueprint I used the node library to get this blueprint function I was able to use ready-made functions like 'OnComponmentBeginOverlap' and 'Set Hidden in Game' which were only available within the Actor class. 


Re-usability - I was able to duplicate the trigger box to use this function on both switches. I could easily re-use this blueprint, the main thing I would need to change is the 'Text Render' Variable to suit what I was hidden in another game.


Time Management


Starting off this prototype I see that I have a lot of tasks to complete, thankfully I have been able to complete one task today. I have 22 days left, so I'm still on target. It's still in the realm of possibility that I'll be able to complete the nine tasks in this amount of time.




Bibliography

Tesla Dev, (2014). Unreal Engine 4 Tutorial - Interactable Button. [online] YouTube. Available at: https://www.youtube.com/watch?v=CflZnd4u33g [Accessed 4 Jan. 2017].

unrealengine, (2014). Collision Response Reference. [online] Docs.unrealengine.com. Available at: https://docs.unrealengine.com/latest/INT/Engine/Physics/Collision/Reference/index.html [Accessed 4 Jan. 2017].

No comments:

Post a Comment