Basics - In prototype 1 there are two switches which activate the casino door to open. As this is the objective for the first level I needed to work out how to create a functioning switch using blueprints.
What - First I needed to remind myself how conditional statements work so I research online and found this website called 'If Statements in C' (Allain, A.2011). This was a good basis to find me when designing these functioning switches.
How-
With help from another student, I was able to out how to a blueprint count the number of switches activated. I first created a custom event called 'Increase Switch count' to reference within the open level blueprint. Next, I created two variable: Switch count and Quota.The 'switch count' counts the number of switches that have been activated. The Quota is the number that has to be meant, so for this quota, the number '2' has to achieved for the quota to be meant. The Quota variable tells the branch node if the quota has been meant. If the quota is meant true then move door position.
The door didn't want to move but because I put 'Print string' into the switch count I could tell that the blueprint was working. I decided that it was something to do with the position movement part was the problem. So I got rid of it and decided to destroy actor.
The next issue I had was when I was making the blueprint within the open level blueprint. I was having issues trying to get the 'Increase switch count' custom event within the open level blueprint. I tried 'Get All Actors of Class' and choose 'Casino Door' next I made a get node and 'cast to Casino Door' to get the custom event. Sadly there was an issue with the cast node.
I realise I didn't need the 'cast' node as 'Get All Actors Of Class' and referencing my custom event was enough to get my it working.
To make it a conditional statement that counted the switches activated I connect the two play camera matinee nodes to the Increase switch count. So when the player activated the matinee that would count for 1 in the switch count variable. When 2 are activated then the quota has been meant and that destroys the door.
Why - While he suggested an easier way to do this function was to have it when the player activates one switch it would open one-half of the door and the other switch would open the other half. This would have been a faster and easier way of coding this function but I wanted to demonstrate conditional statements using the switches.
Industry expectations -
Naming conventions and formatting helped me with this blueprint. As I was referencing a custom event in the open level blueprint I needed to make sure that I had a suitable named for class and event. I wanted to make sure it was clear what was happening in the blueprint to I formatted the open level blueprint into three parts, the two parts for activating the switches and the third that reference the custom event which had the conditional statement.
Ready made libraries - Within the open level I couldn't reference the custom event on it's on but with the ready made code like 'Get All Actors of Class' allowed me to get the custom from my 'Casino Door' blueprint to the open level blueprint.
Re-usability - This blueprint is too dependent on the variables and trigger boxes I made within this project to be easily copied on any other project. Yet there are parts that I have myself which used in my next level. I used a similar layout with similar variables which had a conditional statement if true would destroy the object.
Bibliography
Allain, A. (2011). If Statements in C - Cprogramming.com. [online] Cprogramming.com. Available at: http://www.cprogramming.com/tutorial/c/lesson2.html [Accessed 12 Jan. 2017].
No comments:
Post a Comment