PORTALIZER PACKAGE - 35$
This package contains scripts and shaders that allows you create connected portals, which you can use for fluid Objects or CharacterControllers (scripted manually using template) teleporting. It’s could be a complex object with a couple of renderers and animation. You should have advanced scripting skills, to make it work in your game. You can get this package for FREE (details at the bottom)
IMPORTANT NOTE
This package do not include collision controller disabler. Your objects will collide with colliders behind the portal. This package used for visual part only.
This package requires UnityPro
Where this Portalizer could be helpful?
You can use it in complex scenes, where you don’t want to make holes but they are needed (for example on terrains for buildings or caves). You could connect few locations. You could make very nice eyecandy portals from one part of map to another (for example in RPG). You could use it for simple objects teleporting in games like RollABall or so. You could use it for some physics based games. Finally you could modify scripts and make clone of original Portal game.
REQUIREMENTS
Your object should have collider with rigidbody or CharacterController assigned to object.
You should assign 4 system layers:
8 - “SystemLayer”
9 - “ClonedObject”
10 - “Player”
11 - “MoveObject”
You should add 4 additional tags:
“Player”
“PlayerTemp”
“Portal1”
“Portal2”
Go to Menu → Edit → Project Settings → Physics, and set collision matrix:
“SystemLayer” should NOT collide with “SystemLayer”
“MoveObject” should collide with “SystemLayer”
“ClonedObject” should collide with “SystemLayer”
“MoveObject” should collide with “ClonedObject”
Assign object to “MoveObject” (11) Layer. Now his collider will interact with teleport.
Assign CharacterController to “Player” (10) Layer and his tag set to “PlayerTemp”. Now his controller will interact with teleport.
HOW TO USE PORTALS
- Add both portals from prefab folder on your Scene. (PortalizerResources->Prefabs->PortalX (X mean 1 or 2))
- Make portal as child of wall, if you want to pretend colliding of objects with it.
- Set Portal’s transform.position.y = 0. Now portal is exactly on the wall.
- Go to “Portal X->Active->PortalView(Script)->SecondPortal” variable and assign “other portal active area” to it. Repeat for another portal. (Look example scene)
- Go to “Portal X->InsideZone->PortalGoingThrough(Script)->OtherPortal” variable and assign whole “other portal” to it. Repeat for another portal. (Look example scene)
Now your portals connected, and can easy teleport objects with colliders.
HOW TO MAKE CHARACTERCONTROLLER WORK?
Teleporting of CharacterController(CC) is tricky, and should be scripted manually. The main problem is that CC always much more complex and unique than simple object. It has many scripts and other features (cameras, prefabs e.t.c.) that could differ from game to game, and can not be cloned as is. Usually you would need to clone only some visual parts of CC.
Difference between Objects and CC in teleporting process:
Object : Clone of object would became an original object, and original object would became a clone
CC : Clone and CC will be swapped (switched their places and rotations). It is only illusion of teleporting.
To make it work, you should modify my template => “PortalizerResources->Scripts->ModifiedFpsScript.js”. Use “ModifiedObjectScript.js” script as example.
SHADERS
All object materials should be based on “Self-Illum/Bumped Specular” Shader. Custom shaders not ready yet, but i am working on it.
How to make Custom Masked Shader?
When object placed into the teleport, his shader replaced with ‘“Portlal/Masked/” + Shader.name + " Portal X"’ name of shader.
If you want to make your own custom masked shader for portal, you should follow next few steps: (for example we “creating” masked shader for standard “Diffuse” shader)
- Go to the “PortalizerResources->Shaders->Mask” folder and take TemplateShader.shader. This shader was written by Aras (link on thread http://forum.unity3d.com/threads/11832-Shader-for-Clipping-plane)
- Modify it and make 2 copies with Shader names “Portlal/Masked/Diffuse Portal 1” and “Portlal/Masked/Diffuse Portal 2”. The most important in this scripts, is their names, and _ClipTextureMatrix variable, that should be named as _ClipTextureMatrix_Portal_1 (for Portal 1) and _ClipTextureMatrix_Portal_2 (for Portal 2). As example, look into my MaskIllumBumSpec1.shader and MaskIllumBumSpec2.shader.
FAQ
Q.: Object do not want teleport through portal. It is collide with wall, where portal placed
A.: For object: check his layer. It should be “MoveObject”. Also object should has collider and rigidbody. For CharacterController: his layer should be “Player” and tagged as “PlayerTemp”
Q.: Why CharacterController do not teleported using default scripts?
A.: CC always much more complex than simple object. It has many scripts and other features that could differ from game to game, and can not be cloned as is. Usually you would clone only some visual parts of CC
Q.: Box has been stuck in the teleport or it is teleported partially
A.: It is looks like box hit some collider behind the portal. This package used for visual part only.
Q.: Where i could get masked shaders that will properly work with my object materials?
A.: Package will be updated as soon, as new shaders will be done. Also you can write your custom shaders
Q.: Is this iOS compatible?
A.: Yes, i check it on iPad. The only thing is needed, is to rewrite mask shader (now it is don’t cut objects)
Q.: My object slowdown before teleporting.
A.: Your object move too fast. You could make Inside zone larger to make trigger work like needed.
Q.: Where is inner portal bounds?
A.: You can add them manually. For example use 4 invisible boxes.
Q.: After deploying on Web, masked shader became pink. What to do?
A.: Unity don’t want upload shaders and materials, which are not used on any of scenes (optimization). So you should add empty scene, with cubes that used masked materials, and add this EmptyScene it to “Scenes in Build” list.
Q.: Where this Portalizer could be helpful?
A.: You can use it in complex scenes, where you don’t want to make holes but they are needed (for example in terrains for buildings or caves). You could connect few locations. You could make very nice “eye candy” portals from one part of map to another (for example in RPG). You could use it for simple objects teleporting in games like RollABall or so. You could use it for some physics based games. Finally you could modify scripts and make clone of original Portal game.
CONTACTS
For any questions you could PM me or discuss it in this thread. Email: thegeekgames@gmail.com
You can get this package for FREE:
- You will help me with a couple of customized shaders for default shaders such as “SelfIllum Bumped Specular Shader”, “Diffuse shader”, “SelfIllum Specular Shader” and other (changes goes to all). Details in this thread (package from Aras).
- You will help me with a couple of customized shaders for iOS (changes goes to all). Details in this thread (package from Aras).