Adding Cut Scenes

Create a 3D RPG Game with THREE.js Interacting with the Environment
6 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€65.59
List Price:  €93.70
You save:  €28.11
£56.03
List Price:  £80.05
You save:  £24.01
CA$96.39
List Price:  CA$137.71
You save:  CA$41.31
A$107.98
List Price:  A$154.26
You save:  A$46.28
S$95.50
List Price:  S$136.44
You save:  S$40.93
HK$547.57
List Price:  HK$782.28
You save:  HK$234.70
CHF 64.43
List Price:  CHF 92.05
You save:  CHF 27.61
NOK kr776.82
List Price:  NOK kr1,109.79
You save:  NOK kr332.97
DKK kr489.21
List Price:  DKK kr698.91
You save:  DKK kr209.69
NZ$118.81
List Price:  NZ$169.74
You save:  NZ$50.92
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,729.18
List Price:  ৳11,042.16
You save:  ৳3,312.97
₹5,842.93
List Price:  ₹8,347.41
You save:  ₹2,504.47
RM333.67
List Price:  RM476.70
You save:  RM143.02
₦92,745.84
List Price:  ₦132,499.74
You save:  ₦39,753.90
₨19,599.98
List Price:  ₨28,001.17
You save:  ₨8,401.19
฿2,600.12
List Price:  ฿3,714.62
You save:  ฿1,114.50
₺2,271.31
List Price:  ₺3,244.87
You save:  ₺973.56
B$363.64
List Price:  B$519.51
You save:  B$155.87
R1,308.28
List Price:  R1,869.05
You save:  R560.77
Лв128.30
List Price:  Лв183.29
You save:  Лв54.99
₩96,996.60
List Price:  ₩138,572.52
You save:  ₩41,575.91
₪261.41
List Price:  ₪373.46
You save:  ₪112.04
₱4,045.59
List Price:  ₱5,779.67
You save:  ₱1,734.07
¥11,052.75
List Price:  ¥15,790.32
You save:  ¥4,737.57
MX$1,197.81
List Price:  MX$1,711.23
You save:  MX$513.42
QR257.31
List Price:  QR367.61
You save:  QR110.29
P1,000.11
List Price:  P1,428.79
You save:  P428.68
KSh9,335.98
List Price:  KSh13,337.69
You save:  KSh4,001.70
E£3,349.95
List Price:  E£4,785.86
You save:  E£1,435.90
ብር4,013.63
List Price:  ብር5,734.01
You save:  ብር1,720.37
Kz58,409.45
List Price:  Kz83,445.65
You save:  Kz25,036.20
CLP$67,298.07
List Price:  CLP$96,144.23
You save:  CLP$28,846.15
CN¥506.79
List Price:  CN¥724.02
You save:  CN¥217.23
RD$4,121.81
List Price:  RD$5,888.55
You save:  RD$1,766.74
DA9,423.87
List Price:  DA13,463.25
You save:  DA4,039.38
FJ$159.96
List Price:  FJ$228.52
You save:  FJ$68.56
Q547.38
List Price:  Q782
You save:  Q234.62
GY$14,742.16
List Price:  GY$21,061.13
You save:  GY$6,318.97
ISK kr9,832.89
List Price:  ISK kr14,047.59
You save:  ISK kr4,214.70
DH712.24
List Price:  DH1,017.53
You save:  DH305.29
L1,243.01
List Price:  L1,775.81
You save:  L532.79
ден4,046.68
List Price:  ден5,781.23
You save:  ден1,734.54
MOP$564.08
List Price:  MOP$805.87
You save:  MOP$241.78
N$1,315.96
List Price:  N$1,880.02
You save:  N$564.06
C$2,592.36
List Price:  C$3,703.54
You save:  C$1,111.17
रु9,349.94
List Price:  रु13,357.63
You save:  रु4,007.69
S/263.70
List Price:  S/376.73
You save:  S/113.03
K271.96
List Price:  K388.53
You save:  K116.57
SAR262.49
List Price:  SAR375.01
You save:  SAR112.51
ZK1,886.12
List Price:  ZK2,694.57
You save:  ZK808.45
L326.39
List Price:  L466.29
You save:  L139.90
Kč1,650.20
List Price:  Kč2,357.53
You save:  Kč707.33
Ft25,629.21
List Price:  Ft36,614.73
You save:  Ft10,985.52
SEK kr770.71
List Price:  SEK kr1,101.06
You save:  SEK kr330.35
ARS$61,698.11
List Price:  ARS$88,143.94
You save:  ARS$26,445.82
Bs486.86
List Price:  Bs695.54
You save:  Bs208.68
COP$271,471.23
List Price:  COP$387,832.67
You save:  COP$116,361.43
₡35,819.54
List Price:  ₡51,172.97
You save:  ₡15,353.42
L1,740.31
List Price:  L2,486.27
You save:  L745.95
₲526,285.13
List Price:  ₲751,868.13
You save:  ₲225,582.99
$U2,699.91
List Price:  $U3,857.19
You save:  $U1,157.27
zł284.80
List Price:  zł406.88
You save:  zł122.07
Already have an account? Log In

Transcript

In the game, we want the user to be able to select various buttons that will open doors. To facilitate this, we split the doors off from the objects are they separate objects of their own. And by sliding them in the Zed direction, this particular one, we can slide it into the wall. We could actually add the animation to the scene itself. But we're going to look at adding some custom animation that you can dynamically in the game using tweens. So there we have the two objects that we're going to find.

Now we look at our Loader for our environments SPX. Notice how we've got a door objects, it's going to trigger set to null and proxy array and a doors array. That's because one trigger is going on two doors, because the door is acting as a pairs. If we find the child name includes door proxy, then we add it to our proxy array. And we check our door using this function here, which we'll look at in a moment. If the name includes door, very mind we've already checked the door proxy so so it can't be door proxy, it has to be door on its own.

And we push that into our doors array, and we check the door again. It's not a mash that is a simple No objects, I didn't include the name door No. And that's going to be our trigger. Once we've got a trigger and the proxies of length, the door proxies of length two, and the doors are of length two, we reassigned door and we start looking for some more sets of doors. In the game we've developed for this course, there is only one trigger and two doors. So there are only ever be one of these, but this is how you would do multiple ones of them.

So a game contains a doors array, which contains any number of objects of this form. With a trigger, proxy of length two, and doors of length two. The doors are what we see, the proxy is what we're going to use for blocking things from blocking our Ray caster. So let's have a look again at our automate function. And notice how it's looking through the doors array. Bear in mind, in this particular version of the game, there's only going to be one instance in this doors array.

And it's checking for the distance from the trigger. So the trigger is that Null Object we've created. And that's going to be what we use as the proximity test. If that's less than 100, from where we from where our player is, then we're going to show our action button and we're going to create an action that is going to push button so that's the action that our player character is going to show as an animation. The modes going to be open doors, and this instance, we're hard setting the index to zero but you would actually create a creating an index that is incremented and use the appropriate one. If you had more versions of this.

And we set trigger to true because there's only ever one trigger. So the context action can only be one thing. We use that in order to negate looking for collects because if triggers already set and we won't bother looking at it through this section, but if no triggers are set, then we're going to delete our own action property. Which brings us to context action. Now we can look more carefully at the open doors method that we saw in the previous video. Notice how we use the index value that we've got in our on action object.

We use that to find the appropriate doors object and set that to a constant called door. Left is going to be the first one of our chill children of the Doors, and right is going to be the second. And then we set a camera target and the camera target is going to be based on the position of the left door. And we do some careful repositioning. So we've got a camera in a suitable place. And then we're going to use tweens.

We'll look at the tweens again in the next video. So we will gloss over that we're adding a tween that's what's going to animate the doors to the left and to the right, depending on what which door they are. So let's have a look at how we're using camera target that's in the animate method is defined that our position is going to be whatever our camera target position is. And our target is going to be whatever our camera target is. So that's what we're going to be looking at. We're going to be looking at this particular target from this particular position, which gives us the ability to add a cutscene And then by using camera lookout, he's going to move the camera to the position defined and then look at the position we've described as the target.

Those simple changes allow us to press the button here and the doors open once the doors are finished being and we come back to the default camera

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.