Check out a free preview of the full Game Development with Unity for Web Developers course

The "Falling Sphere Exercise" Lesson is part of the full, Game Development with Unity for Web Developers course featured in this preview video. Here's what you'd learn in this lesson:

Students are instructed to add a Y-height check to RollingMovement to check if the player or opponent has fallen off the board.

Preview
Close

Transcript from the "Falling Sphere Exercise" Lesson

[00:00:00]
>> So next I have an exercise here, and we need a way for both the player and the opponent to get back to their original position if they get knocked off the board, right, so we wanna do this inside of RollingMovement and we want to add a Y-height check.

[00:00:25]
So if the Y position of either of the spheres is below the respawn height that we created in the GameManager, we should reset the position of the sphere. So if the spheres fall off the side of the board, we should reset the position and remember again, in the GameManager we created a globally accessible static variable to hold what the respawn height should be, you should use that to reset the position here.

[00:00:58]
And again, this is a snippet of code, but inside a fixed update you want to do this on the RollingMovement component.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now