Creating a Simplified Version of Your Environment

Create a 3D RPG Game with THREE.js Moving Around Your Environment
4 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
€60.89
List Price:  €86.99
You save:  €26.10
£52.07
List Price:  £74.39
You save:  £22.31
CA$95.66
List Price:  CA$136.66
You save:  CA$41
A$107.87
List Price:  A$154.11
You save:  A$46.23
S$89.96
List Price:  S$128.52
You save:  S$38.56
HK$549.41
List Price:  HK$784.90
You save:  HK$235.49
CHF 57.18
List Price:  CHF 81.69
You save:  CHF 24.51
NOK kr696.88
List Price:  NOK kr995.59
You save:  NOK kr298.70
DKK kr454.18
List Price:  DKK kr648.86
You save:  DKK kr194.67
NZ$116.27
List Price:  NZ$166.11
You save:  NZ$49.83
د.إ257.03
List Price:  د.إ367.21
You save:  د.إ110.17
৳8,556.39
List Price:  ৳12,223.94
You save:  ৳3,667.54
₹6,053.68
List Price:  ₹8,648.48
You save:  ₹2,594.80
RM297.49
List Price:  RM425
You save:  RM127.51
₦108,117.05
List Price:  ₦154,459.55
You save:  ₦46,342.50
₨19,824.96
List Price:  ₨28,322.58
You save:  ₨8,497.62
฿2,283.77
List Price:  ฿3,262.67
You save:  ฿978.90
₺2,767.39
List Price:  ₺3,953.59
You save:  ₺1,186.19
B$385.16
List Price:  B$550.25
You save:  B$165.09
R1,266.96
List Price:  R1,810.02
You save:  R543.06
Лв118.96
List Price:  Лв169.95
You save:  Лв50.99
₩96,270.46
List Price:  ₩137,535.12
You save:  ₩41,264.66
₪245.25
List Price:  ₪350.37
You save:  ₪105.12
₱4,005.07
List Price:  ₱5,721.77
You save:  ₱1,716.70
¥10,136.24
List Price:  ¥14,480.97
You save:  ¥4,344.72
MX$1,328.99
List Price:  MX$1,898.65
You save:  MX$569.65
QR254.87
List Price:  QR364.12
You save:  QR109.24
P935.34
List Price:  P1,336.27
You save:  P400.92
KSh9,042.70
List Price:  KSh12,918.70
You save:  KSh3,876
E£3,537.81
List Price:  E£5,054.24
You save:  E£1,516.42
ብር9,434.65
List Price:  ብር13,478.65
You save:  ብር4,044
Kz63,827.73
List Price:  Kz91,186.38
You save:  Kz27,358.65
CLP$66,028.30
List Price:  CLP$94,330.18
You save:  CLP$28,301.88
CN¥503.11
List Price:  CN¥718.76
You save:  CN¥215.65
RD$4,143.56
List Price:  RD$5,919.63
You save:  RD$1,776.06
DA9,122.93
List Price:  DA13,033.32
You save:  DA3,910.38
FJ$157.35
List Price:  FJ$224.80
You save:  FJ$67.44
Q537.34
List Price:  Q767.66
You save:  Q230.32
GY$14,631.99
List Price:  GY$20,903.73
You save:  GY$6,271.74
ISK kr8,744.55
List Price:  ISK kr12,492.75
You save:  ISK kr3,748.20
DH637.97
List Price:  DH911.42
You save:  DH273.45
L1,198.56
List Price:  L1,712.31
You save:  L513.74
ден3,743.35
List Price:  ден5,347.88
You save:  ден1,604.52
MOP$565.68
List Price:  MOP$808.15
You save:  MOP$242.47
N$1,248
List Price:  N$1,782.94
You save:  N$534.93
C$2,572.13
List Price:  C$3,674.63
You save:  C$1,102.50
रु9,649.16
List Price:  रु13,785.10
You save:  रु4,135.94
S/252.38
List Price:  S/360.56
You save:  S/108.17
K288.44
List Price:  K412.08
You save:  K123.63
SAR262.58
List Price:  SAR375.13
You save:  SAR112.55
ZK1,703.23
List Price:  ZK2,433.29
You save:  ZK730.06
L306.34
List Price:  L437.65
You save:  L131.30
Kč1,510.94
List Price:  Kč2,158.58
You save:  Kč647.64
Ft24,581.78
List Price:  Ft35,118.33
You save:  Ft10,536.55
SEK kr671.18
List Price:  SEK kr958.87
You save:  SEK kr287.69
ARS$81,364.44
List Price:  ARS$116,239.90
You save:  ARS$34,875.45
Bs485.21
List Price:  Bs693.19
You save:  Bs207.97
COP$289,211.13
List Price:  COP$413,176.46
You save:  COP$123,965.33
₡35,234.35
List Price:  ₡50,336.95
You save:  ₡15,102.59
L1,830.23
List Price:  L2,614.73
You save:  L784.50
₲558,871.53
List Price:  ₲798,422.12
You save:  ₲239,550.59
$U2,868.51
List Price:  $U4,098.05
You save:  $U1,229.54
zł260.38
List Price:  zł372
You save:  zł111.61
Already have an account? Log In

Transcript

In this version of the game version four, you can see that Yeah, the character actually conforms to the environment. And if you run into things, it stops. achieve that. Here's the model. And you can see it's quite complicated. It has 34,000 polygons, 34,000 points and nearly 33,000 polygons.

What we do is we create a simplified version of it. So you can see all we've done there is create boxes share box shapes that match our geometry. simplified version versions of the geometry is going to be used by the ray caster. You can see the outline of them the and they, we give that the name environment proxy so that we can find it in the SPX file that we've exported. And one or two other items in there. Namely, adore proxy adore itself Various funds are ready to rotate.

So yes, the simplified version of the geometry is the way to go for you ray casting so that we can conform to the environment. We have a look at the code for that. And looking at version four of the code. And if we look at our move player, then we use the environment proxy that we found when we loaded in and we're doing exactly the same thing as we were doing with the simple simple yellow boxes. Only we're also casting down because we also need to allow it to go up and down. We can ask From about two meters above both our Y position, our Y position is at our feet.

So in other words, it's just above our head. And we're casting on the environment proxy. Did we find an intersection, we need to know where that is, whether or not it's above or below the place current position. If it's above that, if it's above the place current position, we blend up to that point by adapting our y value to be 80% of current position, and 20% of the target y and we set our velocity which we're going to use for when she's dropping to zero in the target y is below our feet. She must be falling. If we haven't set a velocity for the y value, then we initialize it to zero.

And then we add whatever our delta time is times gravity and increase our velocity by that amount. And then we subtract that value from our Y position. And if it's gone under our target, then we set our velocity to zero. And we set our position y to where the target is, so it conforms to that point. And then we have the ability to run and fall

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.