Section 4- Level Building, More Scripting, and Publishing



26) Extend floor and build a small level. (In appropriate hierarchy)
Increase the scale of the ground plane to give more playing area.

Make a simple maze by creating and duplicating scaled cubes.

Make sure all the GameObjects are organized in the Hierarchy.


27) Make a moving wall.
Add a RigidBody to a wall and mark it as kinematic.

Write a script to make it move. Completed C# MovingWall example: here.


28) Experiment with physics of the moving wall.
Allow the moving wall to push the Player into a wall. The physics engine won't allow it and (probably) handles the overlap correctly.

If you want the overlap to be prevented, you'd have to do a "cast" in front of the moving wall before it moves, and then cast in front of anything it will push to make sure there's room.


29) Organize Assets in the Project view
Make "Scripts" folder inside Assets and put the 2 scripts in there.

Unity automatically tracks moving assets.
Do not move / rename / delete assets externally! (With Windows Explorer, etc.)


30) Position camera and make CameraMovement script.
Find a good looking position for the camera, then make a script to move it with the Player.
Completed C# CameraMovement example: here.

Camera following code should be in the LateUpdate function so it happens last in frame after all input and movement is handled.

GameObjects or their components (such as Transform) can be public variables in a script. Then GameObjects can be dragged from the Hierarchy to populate those fields.


31) Build project (publish)
Select "File -> Build Settings" from the top menu bar.

Select target platform, etc. and then click "build."





Prev: Section 3- Basic Physics and Scripting
Next: Section 5- Triggers, Materials, and PreFabs

Back to Main