Portals / scene-shifts

Heyas all;

First Id like to point out I feel a little silly for having to ask this but here goes

Im very new to Unity (try only a week) but have some pretty big plans for something I would like to build and one of the areas Im finding very little on is being able to make portals or scene shifts

The easiest way to explain this is I have a terrain that is meant to have lots and lots of caves in it (I know this would have to be modelled externally to unity if I was to make it as a whole piece) However as there are over a thousand possible interiors I dont want to have the all simultaneously rendered.

What I would like to do is have the equivalent of holes or dents in the terrain mesh that can be crossed over (without falling through the map) which would trigger taking the player controller to another scene or insider the cave in question.

Is there any way to do this? In the free version of unity?

Also; other things to add on would be that, some rooms will have more than one exterior entrance and one room type would have to be generated randomly out of a possible five pre-sets.

From what I have been able to work out this is probably more to do with coding than the aesthetic drag and drop function of unity. As its moving a player to a new scene based on co-ordinates crossed and where they would be re-appearing.

Thanks in advance; and sorry if its not very clear. ~ Christina

1 Answer

1

What you would want to do if i understand your first question correctly, is set some gameobjects where you want the character to "fall through" or cross over, and set that as a trigger (in the section in the hierarchy/inspector where it has the collider it says "is trigger", check that box). set the tag, which is in the upper section of the inspector under the objects name, set this to something like, holes or dents or whatever works best for you. After that, this is the code that you will want and attach that javascript to the collider, and obj would be whatever scene you would want it to switch to which is added in File>Build Settings. And after that, you could even put a random number generator between 1 and 5 and put that into the space where obj is. Hope this helps:

` var obj = 0;

function OnTriggerEnter( hit : Collider) { if(hit.gameObject.tag == "player") { Application.LoadLevel(obj); } }

`

btw, also uncheck the mesh renderer so the level loader is invisible