Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Unity for Architectural Visualization

You're reading from  Unity for Architectural Visualization

Product type Book
Published in Sep 2013
Publisher Packt
ISBN-13 9781783559060
Pages 144 pages
Edition 1st Edition
Languages
Author (1):
Stefan Boeykens Stefan Boeykens
Profile icon Stefan Boeykens

Further interactions


We finish this chapter with some more useful techniques.

Resetting the player

What if, at one point, the user reaches the edge of the terrain or world you created and falls off? Instead of expecting the user to quit and restart, you should solve the problem elegantly. We place a large, invisible plane underneath our world, as a trigger to reset the player.

  1. Add a Plane GameObject and set its Mesh Collider to Is Trigger. Make it large enough to extend to all sides of the scene and move it down underneath all other objects, as in the setup in the next screenshot.

  2. Disable its Mesh Renderer, to make it invisible.

  3. Create a new C# script called resetPlayer and add the following code. It takes three private variables: one for the player's position (pos), one for its rotation (rot), and then the actual reference to the player (thePlayer). This is shown in the following code:

    using UnityEngine;
    using System.Collections;
    public class resetPlayer : MonoBehaviour {
      private Vector3 pos...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}