Staying Within Bounds in Unity

Veröffentlicht am: 02 Februar 2019
auf dem Kanal: Omar Santiago
11,518
152

So you are making a 3D game and you are wondering how do I keep my players and gameobjects from moving right off the screen or from moving off the world? You can do it a number of ways. I used my imagination and came up with two ways.

1st way I tried was placing some walls around my scene that the player would collide with and no be able to pass. I can make the walls invisible by turning off the mesh renderer.

2nd way is a little more thoughful. I use an very large 3D object to encase my scene within. Then I use the Is Trigger flag on the collider. I detect when the player exits the object and push player back in.

Check out the video to see how I did both ways...

Source Code: https://github.com/omarvision/staying...

Omarvision game programming tutorials, unity game engine. http://www.omarvision.com. Free classes at Microsoft Store - International Plaza 2223 N. West Shore Blvd, Tampa FL 33607


Auf dieser Seite können Sie das Online-Video Staying Within Bounds in Unity mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Omar Santiago 02 Februar 2019 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 11,518 Mal angesehen und es wurde von 152 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!