Chapter 2 Errata
For those of you who have picked up my book already, thank you. I hope the book is as fun to read as it was for me to write and good luck on your future UE4 projects.
A special thank you to to reader Lukas in Germany, he caught a bit of an error on my part in Chapter 2. Please utilize the following on page 24:
- Everything working? You may have noticed that when the door opens, it slides away forever. Not very useful. This is due to the player triggering the door multiple times by standing in the box trigger. To fix this, we need to change the math in our Blueprint to add the initial location of the door to our Timeline value, rather than getting the door’s location repeatedly. To do that first grab an Event Begin Play node from the Palette. This can be from the Find a Node search box or it is marked in the Favorites section in the top portion of the panel. Next, create a Variable by clicking the + button in the Variables section of the My Blueprint panel and name it Door 1 Initial. Variables in Blueprint work just like they do in everyday math, they store information. However, variables in Blueprint can store much more than just numbers, they can hold almost anything. This variable will store the initial position of our door so that we can add it to our value that is animated by the Timeline. With our new variable selected, head down to the Details panel in the lower left portion of the screen and change the Variable Type to Vector.
- Time to wire it up! Drag the Door 1 Initial variable into the Blueprint and place it next to the Event Begin Play node. It will ask you whether you would like to Get or Set our variable, use Set. Grab a Get Actor Location node and plug that into the vector value on the left side of the Set node. Finally, set the door as its Target. Now just replace the Get Actor Location in the Door sequence with a Get version of our variable and we are all set! Make sure to follow the process again for the second door at the other end of the hallway.
Hope this helps!