Search Unity

[RELEASED] Gater (Portals System)

Discussion in 'Assets and Asset Store' started by Deleted User, Apr 5, 2016.

  1. chris-z562

    chris-z562

    Joined:
    Jul 11, 2012
    Posts:
    41
    @H92 I might see if I can fix it. I'm guessing it's somewhere in the ShaderForge-made UVRemap.shader. Do you agree?
     
  2. Deleted User

    Deleted User

    Guest

    This project is totally open source.

    You can do whatever you want, but only if the work will posted here (as usual).
     
    Last edited by a moderator: Aug 14, 2017
  3. gonzalologorg

    gonzalologorg

    Joined:
    Jan 2, 2014
    Posts:
    2
    I'm facing the same issues with portals





    If you go closer, it works well, but at a far distance, portal just glitches, i'm also looking into getting support for ufps, i'll email this guy
     
  4. chris-z562

    chris-z562

    Joined:
    Jul 11, 2012
    Posts:
    41
    @gonzalologorg Are you on mac? And does it work well in editor, but not in a build?
     
  5. gonzalologorg

    gonzalologorg

    Joined:
    Jan 2, 2014
    Posts:
    2
    Windows 10 64 bits and same result in editor and build, I'm using your character controller and prefabs, also I have a GTX 970

    Also

    I've contacted to ufps author and they are willing to give a copy if you contact them
    ufps@opsive.com

    Thank you so much for what are you doing for the community
     
    Last edited: Aug 10, 2017
  6. chris-z562

    chris-z562

    Joined:
    Jul 11, 2012
    Posts:
    41
    @gonzalologorg I'm not the author. I'll return with a solution to the flickering if I find one
     
  7. blade32232

    blade32232

    Joined:
    Aug 11, 2017
    Posts:
    12
    how do I exclude an object from rendering, as when I put a part of a wall into the exclude list it doesn't disappear from the portal.
     
  8. Deleted User

    Deleted User

    Guest

    Hey folk!

    If anyone of you want to open a GitHub page, can do it.

    I think it's a better way of working at this point.
     
  9. Deleted User

    Deleted User

    Guest

    Hi everyone.

    Version 1.3.5 has been submitted. Changelog:

    - Fixed a bug where far distance generate a black render.

    RELEASED!
     
    Last edited by a moderator: Aug 21, 2017
  10. b4c5p4c3

    b4c5p4c3

    Joined:
    Jan 4, 2013
    Posts:
    537
    Wow just found this asset like 30 mins ago and i'm having so much fun with it.

    Thank you
     
  11. blade32232

    blade32232

    Joined:
    Aug 11, 2017
    Posts:
    12
    Hi, is it possible to enable HDR on the cameras for the portals?
     
  12. Deleted User

    Deleted User

    Guest

    Yes. You just only enable it on main camera, and the remains portals cameras acquire the same option.
     
  13. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    First of all, thank you for the amazing asset.

    I'm trying to embed the portals (I got rid of the cube frames) into my scene, into a door:
    upload_2017-8-19_3-24-23.png

    I've got a portal between this door, and another similar door far away in world space (not crazy far, but far enough).

    The problem is, when I start the scene it seems that Gater is cloning virtually every object and mesh from the other scene. I'm guess this is because somehow the colliders from the other objects (walls/floors/etc) are slightly intersecting with the mesh collider of Gater (if I understand how it works correctly).

    This is what happens visually:
    upload_2017-8-19_3-37-34.png

    I'm trying to modify the script that would ONLY allow cloning of the object that has the FirstPersonController component, but for some reason when I'm trying to catch collisions in OnTriggerEnter I only see 1 GameObject triggering it (doing a naive Debug.Log(collision.gameObject.name).

    Also, even when adding objects to the portal ignore list, they still get cloned? Or am I imagining that list doesn't do what I think it does.
    upload_2017-8-19_3-38-28.png
    upload_2017-8-19_3-39-27.png

    Do you have any insight how I could possibly just limit all cloning to only the FPC object? Thank you again!
     
    Last edited: Aug 19, 2017
  14. blade32232

    blade32232

    Joined:
    Aug 11, 2017
    Posts:
    12
    Well I have HDR set on the main fpscontroller camera but hdr isn't showing on portal
     

    Attached Files:

  15. Deleted User

    Deleted User

    Guest

    Maybe Exclude feature not work properly (i will check next week, when I will return to home).

    But if you want, you can check yourself the for cycle on OnTriggerEnter, that compare all triggered objects with "exluded objects" array to stop execution.
     
    Last edited by a moderator: Aug 19, 2017
  16. Deleted User

    Deleted User

    Guest

    If it's set on portal cameras, and still not working, so there is a problem on shader (in this case I must find a better way to make it).
     
  17. blade32232

    blade32232

    Joined:
    Aug 11, 2017
    Posts:
    12
    well when I have the game running and check the cameras they seem to not have HDR set on while the main fpscontroller camera does.
     
  18. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    If I do Debug.Log(collision.gameObject.name) right inside "OnTriggerEnter", should it print every gameobject that is processed by the PortalManager?

    Because right now it doesn't :/ Oddly enough, even if I disable the Mesh Collider on the 2nd gate, so essentially I thought I would make a one way travel gate, it seems to have no effect. I'll try to dig myself today on it. Is it possible you can share some overview of how the script should work?

    Note: I'm not using your FirstPersonController as I modified the standard one quite a bit. If the general functionality of walking through portals work (and it does), can I ignore your FPC?

    Thanks!
     
  19. Deleted User

    Deleted User

    Guest

    As usual I will check after that I return to home (monday).
     
  20. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    OK, I've figured out how to at least hack around my problem, now things are working great.

    I've simply added a check to only process objects that start with "PlayerFPC", which is the name of my object containing the FirstPersonController script. I say "start with" because PortalManager creates clones with different names, but they always start with your base object name.

    My edit:

    Code (CSharp):
    1. # just after OnTriggerEnter, OnTriggerStay, OnTriggerExit
    2. if (collision.gameObject.name.Substring(0, collision.gameObject.name.Length > 9 ? 9 : collision.gameObject.name.Length) != "PlayerFPC")
    3.     return;
    After that everything is working fine and I'm using my FPC script.

    Not sure what you changed in yours, I will try to investigate at a later day because for now its working OK, but maybe if you had a brief overview of FPC changes folks could integrate easier the required changes :)
     
  21. Deleted User

    Deleted User

    Guest

    In pratice you want to use you own FPS Controller with a different name?
     
  22. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    Not sure I understand the question. I am using a modified version of the Unity Standard Assets FirstPersonController (I changed the namespace of my script as well for my sanity). The first thing I did to PortalManager was replace the fully qualified reference to FirstPersonController to just FirstPersonController and reference the correct assembly with the "using" directive.

    That got the script compiling and working fine on your test scenes.

    Then I wanted to further modify PortalManager to *only work on my FirstPersonController* (which is on a GameObject named "PlayerFPC"). I managed to do that with the code snippet pasted.

    The last questions I have (which are not so important) is what is the actual diff between the Unity Standard Assets FPC script, and the FPC script you distribute.
     
  23. Deleted User

    Deleted User

    Guest

    I wanted to say if you want only to use my script with different FPS Controller namespace, but I have understand that you only want to add a check with your script name. In this case you must only obviously add a further check.

    When I return to home I will try to provide a universal solution.
     
  24. Deleted User

    Deleted User

    Guest

    To answer to your latest question...I have changed some lines on Start function of FPSController main script, and others on MouseLook (you will find instantly if you compare it).
     
  25. blade32232

    blade32232

    Joined:
    Aug 11, 2017
    Posts:
    12
    Would having the ability to lock the camera rotation between two points or set angles around the plane remove the problem of having objects close to the portal get in the way? like in the image attached or would that be fixed another way?
    Clipping.PNG
     
  26. Deleted User

    Deleted User

    Guest

    Try to exclude the object from rendering with built-in portal manager feature.
     
  27. blade32232

    blade32232

    Joined:
    Aug 11, 2017
    Posts:
    12
    When I try and use the exclude list it doesn't work for any objects.
     
  28. Deleted User

    Deleted User

    Guest

    Strange, exclude list of rendering work for me on 'fps with wall' example.
     
  29. blade32232

    blade32232

    Joined:
    Aug 11, 2017
    Posts:
    12
    Alright I got the exclude working by changing the layer the object is on, but what I need is that object to be there as it's like a corridor, but I don't want to see the other side of it, or is that jut not possible at the moment with this?
     
  30. Deleted User

    Deleted User

    Guest

    So you want to make a corridor between the entrance and exit, right? Ok, you can do it in a simple way with 4 portals (two in and out from your world to a corridor, and other two from corridor to other world that you want to reach).
     
  31. blade32232

    blade32232

    Joined:
    Aug 11, 2017
    Posts:
    12
    I just meant that it was like a corridor because it has walls surrounding the portal. you can see what I mean here.
     
  32. Deleted User

    Deleted User

    Guest

    I suggest you to use a wall with hide front face, in this way you may can fix the problem.
     
  33. blade32232

    blade32232

    Joined:
    Aug 11, 2017
    Posts:
    12
    Not sure what you mean by this as i'm a beginner with unity. Are you talking about a stencil buffer?
     
    Last edited: Aug 21, 2017
  34. Deleted User

    Deleted User

    Guest

    Hi everyone.

    Version 1.3.6 has been submitted. Changelog:

    - Fixed a bug where: occlusion culling, hdr and msaa, were not enabled/disabled on portals cameras with main scene camera.
    - Excluded objects from trigger has been rewritten.

    RELEASED!
     
    Last edited by a moderator: Aug 22, 2017
  35. Deleted User

    Deleted User

    Guest

    Nope, i'm talking about face rendering. Add a plane to your scene (from unity default mesh) and you can see that one face is visible and one not. You can make a wall without one face visible, and maybe you can solve the problem.
     
  36. blade32232

    blade32232

    Joined:
    Aug 11, 2017
    Posts:
    12
    I don't think that will work as the wall is meant to be visible from both sides, as such I will see if stencil masks will help with this probelm.
     
  37. blade32232

    blade32232

    Joined:
    Aug 11, 2017
    Posts:
    12
    I can officially say that using stencil masks is exactly what I needed, with a bit more customization I can get it working perfectly.
     
  38. blade32232

    blade32232

    Joined:
    Aug 11, 2017
    Posts:
    12
    I'm not sure if it's just me, but after I updated and reimported the package, I seem to be turning left as soon as I'm through the other side.

    update: It seems that when ever i'm crossing through once i've fully gone through the rotation of the fps controller get set to the same as the first portal you walk through, or something like that.
     
    Last edited: Aug 23, 2017
  39. Level_Up

    Level_Up

    Joined:
    Sep 25, 2017
    Posts:
    1
    I've been testing this asset using the FPS scene. I've found that if I rotate the blue portal when I go to the other side I face the red cube for half a second, then I quickly rotate. Otherwise, it works wonderfully. Why is this happening?
     
  40. Deleted User

    Deleted User

    Guest

    Maybe I have understand which is the problem.

    I will fix it on next version.
     
  41. Deleted User

    Deleted User

    Guest

    Hi.

    Have you updated to the latest version? Exclude objects from trigger work for me.

    P.S = There isn't a way to donate. :)
     
    Last edited by a moderator: Oct 6, 2017
  42. Deleted User

    Deleted User

    Guest

    Hi everyone.

    Version 1.3.7 has been submitted. Changelog:

    - You can now manually set clip plane material for clone objects.
    - FPS Skybox scene has been fixed.
     
  43. Deleted User

    Deleted User

    Guest

    Can you try the portals on one of example scene into the package, In the same situation but without room model?

    I before understand if it's a general problem, or a issue restricted only to your scene. Because maybe you must create a model without back or front face, in order to allow portal cameras to rendering correctly inside it.
     
    Last edited by a moderator: Oct 6, 2017
  44. Deleted User

    Deleted User

    Guest

    I think that you must see the code inside the trigger functions (those relegated to cloning objects to secondary portal).

    In the same way you can create a raycast, from first to second portal.
     
  45. boxhallowed

    boxhallowed

    Joined:
    Mar 31, 2015
    Posts:
    513
    I am running into an issue that is completely baffling me. Sometimes, more rarely after I made some changes but still happening, the screen flashes with the color of the skybox. It's like the collision overshoots and you see the skybox before being teleported. I tried putting all the trigger events on co-routines and firing them on yield null, and then putting my character mover routine on yield return new WaitForFixedUpdate(), to try and separate the events. I'm still getting that flicker. Additionally, I even tried making the portalmanager.cs fire before the Player controller script. It's still doing it.

    Here are the changes I've made to PortalManager.cs.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.SceneManagement;
    3. using System;
    4. using System.Collections;
    5. #if UNITY_EDITOR
    6.     using UnityEditorInternal;
    7.     using UnityEditor;
    8. #endif
    9.  
    10. [ExecuteInEditMode]
    11. [DisallowMultipleComponent]
    12.  
    13. [RequireComponent (typeof(MeshFilter))]
    14. [RequireComponent (typeof(MeshRenderer))]
    15. [RequireComponent (typeof(Rigidbody))]
    16.  
    17. public class PortalManager : MonoBehaviour {
    18.     //Public vars and related
    19.     [Serializable] public class AutoPairClass {
    20.         public bool Enable;
    21.  
    22.         public string PortalPairedName;
    23.     }
    24.  
    25.     public AutoPairClass AutoPair;
    26.  
    27.     public GameObject PairedPortal;
    28.     private bool ClearPairedPortal;
    29.     public Material PairedPortalSkybox;
    30.  
    31.     public bool bTeleporterActive = true;
    32.  
    33.     [Serializable] public class ViewSettingsClass {
    34.         [Serializable] public class ProjectionClass {
    35.             public Vector2 Resolution = new Vector2(800, 600);
    36.  
    37.             public enum DepthQualityEnum {Fast, High};
    38.             public DepthQualityEnum DepthQuality = DepthQualityEnum.High;
    39.             [HideInInspector] public DepthQualityEnum CurrentDepthQuality;
    40.         }
    41.         public ProjectionClass Projection;
    42.  
    43.         [Serializable] public class RecursionClass {
    44.             [Range(1, 20)] public int Steps = 1;
    45.             public Material CustomFinalStep;
    46.         }
    47.         public RecursionClass Recursion;
    48.  
    49.         [Serializable] public class DistorsionClass {
    50.             public bool EnableDistorsion;
    51.  
    52.             public Texture2D Pattern;
    53.             public Color Color = new Color(1, 1, 1, 1);
    54.             [Range(1, 100)] public int Tiling = 1;
    55.             [Range(-10, 10)] public float SpeedX = .01f;
    56.             [Range(-10, 10)] public float SpeedY = 0;
    57.         }
    58.         public DistorsionClass Distorsion;
    59.     }
    60.     public ViewSettingsClass ViewSettings;
    61.  
    62.     [Serializable] public class PortalSettingsClass {
    63.         public bool EnableRender = true;
    64.         public bool EnableObjsTrigger = true;
    65.         public bool EnableClipPlane = true;
    66.     }
    67.     public PortalSettingsClass PortalSettings;
    68.  
    69.     [Serializable] public class PortalFunctionalityClass {
    70.         public GameObject[] ExcludedObjsFromTrigger = new GameObject[0];
    71.  
    72.         [Serializable] public class ExcludedObjsFromRenderClass {
    73.             public GameObject Obj;
    74.  
    75.             [Range(2, 31)] public int Layer = 2;
    76.         }
    77.         public ExcludedObjsFromRenderClass[] ExcludedObjsFromRender = new ExcludedObjsFromRenderClass[0];
    78.  
    79.         [Serializable] public class SceneAsyncLoadClass {
    80.             public bool Enable;
    81.  
    82.             public int SceneIndex = 0;
    83.         }
    84.         public SceneAsyncLoadClass SceneAsyncLoad;
    85.     }
    86.     public PortalFunctionalityClass PortalFunctionality;
    87.     //----------
    88.  
    89.     private Material[] PortalMaterials;
    90.     private RenderTexture[] RenderTexts;
    91.     private Material ClipPlaneMaterial;
    92.     private Material CloneClipPlaneMaterial;
    93.     [HideInInspector] public GameObject ClipPlanePosObj;
    94.     private Vector2 CurrentProjectionResolution;
    95.     [HideInInspector] public GameObject[] PortalCamObjs;
    96.     private int[] InitPortalCamObjsCullingMask;
    97.     private GameObject SceneviewRender;
    98.  
    99.     void OnEnable () {
    100.         #if UNITY_EDITOR
    101.             RenderTexts = new RenderTexture [2];
    102.         #else
    103.             RenderTexts = new RenderTexture [1];
    104.         #endif
    105.         PortalMaterials = new Material [RenderTexts.Length];
    106.  
    107.         PortalCamObjs = new GameObject [20];
    108.         Array.Resize (ref PortalCamObjs, PortalCamObjs.Length + 1);
    109.         InitPortalCamObjsCullingMask = new int [PortalCamObjs.Length];
    110.  
    111.         for (int i = 0; i < PortalMaterials.Length; i++) //Generate "Portal" and "Clipping plane" materials
    112.             if (!PortalMaterials [i])
    113.                 PortalMaterials [i] = new Material (Shader.Find ("Gater/UV Remap"));
    114.  
    115.         Shader ClipPlaneShader = Shader.Find ("Clip/Plane");
    116.  
    117.         if (!ClipPlaneMaterial) {
    118.             ClipPlaneMaterial = new Material (Shader.Find ("Standard"));
    119.             ClipPlaneMaterial.shader = ClipPlaneShader;
    120.         }
    121.         if (!CloneClipPlaneMaterial) {
    122.             CloneClipPlaneMaterial = new Material (Shader.Find ("Standard"));
    123.             CloneClipPlaneMaterial.shader = ClipPlaneShader;
    124.         }
    125.  
    126.         //Apply custom settings to the portal components
    127.         GetComponent<MeshRenderer> ().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
    128.         GetComponent<MeshRenderer> ().receiveShadows = false;
    129.         GetComponent<MeshRenderer> ().sharedMaterial = PortalMaterials [0];
    130.         GetComponent<Rigidbody> ().mass = 1;
    131.         GetComponent<Rigidbody> ().drag = 0;
    132.         GetComponent<Rigidbody> ().angularDrag = 0;
    133.         GetComponent<Rigidbody> ().useGravity = false;
    134.         GetComponent<Rigidbody> ().isKinematic = true;
    135.         GetComponent<Rigidbody> ().interpolation = RigidbodyInterpolation.None;
    136.         GetComponent<Rigidbody> ().collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
    137.         GetComponent<Rigidbody> ().constraints = RigidbodyConstraints.None;
    138.         if (GetComponent<MeshCollider> ()) {
    139.             GetComponent<MeshCollider> ().convex = true;
    140.             GetComponent<MeshCollider> ().sharedMaterial = null;
    141.         }
    142.  
    143.         //Disable collision of walls behind portals, and check if the excluded objects from trigger have a collider component
    144.         if (PortalFunctionality.ExcludedObjsFromTrigger.Length > 0)
    145.             for (int j = 0; j < PortalFunctionality.ExcludedObjsFromTrigger.Length; j++)
    146.                 if (PortalFunctionality.ExcludedObjsFromTrigger [j])
    147.                     if (!PortalFunctionality.ExcludedObjsFromTrigger [j].GetComponent<Collider> ())
    148.                         Debug.LogError ("One excluded wall doesn't have a collider component");
    149.  
    150.             #if UNITY_EDITOR
    151.                 EditorApplication.update = null;
    152.                
    153.                 //Search already existing required objects for teleport, and fill the relative variables with
    154.                 int PortalCamObjsSteps = 0;
    155.  
    156.                 for (int k = 0; k < transform.GetComponentsInChildren<Transform> ().Length; k++) {
    157.                     if (transform.GetComponentsInChildren<Transform> () [k].name == this.gameObject.name + " Camera " + PortalCamObjsSteps) {
    158.                         PortalCamObjs [PortalCamObjsSteps] = transform.GetComponentsInChildren<Transform> () [k].gameObject;
    159.  
    160.                         PortalCamObjsSteps += 1;
    161.                     }
    162.  
    163.                     if (transform.GetComponentsInChildren<Transform> () [k].name == transform.name + " SceneviewRender")
    164.                         SceneviewRender = transform.GetComponentsInChildren<Transform> () [k].gameObject;
    165.  
    166.                     if (transform.GetComponentsInChildren<Transform> () [k].name == transform.name + " ClipPlanePosObj")
    167.                         ClipPlanePosObj = transform.GetComponentsInChildren<Transform> () [k].gameObject;
    168.                 }
    169.             #endif
    170.     }
    171.  
    172.     private Mesh PortalMesh;
    173.     private Camera InGameCamera;
    174.     private RenderTexture TempRenderText;
    175.  
    176.     void LateUpdate () {
    177.         if (!PairedPortal || PairedPortal.GetComponent<PortalManager> ().PairedPortal != gameObject) {
    178.             if (ClearPairedPortal) {
    179.                 PairedPortal = null;
    180.  
    181.                 ClearPairedPortal = false;
    182.             } else
    183.                 if (AutoPair.Enable) {
    184.                     if (AutoPair.PortalPairedName != "")
    185.                         PairedPortal = GameObject.Find (AutoPair.PortalPairedName);
    186.                 } else
    187.                     for (int i = 0; i < FindObjectsOfType<Transform> ().Length; i++)
    188.                         if (FindObjectsOfType<Transform> () [i] != transform && FindObjectsOfType<Transform> () [i].GetComponent<PortalManager> () && FindObjectsOfType<Transform> () [i].GetComponent<PortalManager> ().PairedPortal == gameObject)
    189.                             PairedPortal = FindObjectsOfType<Transform> () [i].gameObject;
    190.         } else {
    191.             if (!InGameCamera) {
    192.                 ResetVars (false); //Reset arrays elements of the required objects for teleport, if game camera variable is null and any object is still colliding with the portal
    193.  
    194.                 InGameCamera = Camera.main; //Fill empty "InGameCamera" variable with main camera
    195.             } else {
    196.                 ClearPairedPortal = true;
    197.  
    198.                 if (InGameCamera.nearClipPlane > .01f)
    199.                     Debug.LogError ("The nearClipPlane of 'Main Camera' is not equal to 0.01");
    200.  
    201.                 PortalMesh = GetComponent<MeshFilter> ().sharedMesh; //Acquire current portal mesh
    202.  
    203.                 ViewSettings.Projection.Resolution = new Vector2 (ViewSettings.Projection.Resolution.x < 1 ? 1 : ViewSettings.Projection.Resolution.x, ViewSettings.Projection.Resolution.y < 1 ? 1 : ViewSettings.Projection.Resolution.y);
    204.  
    205.                 //Generate render texture for the portal camera
    206.                 if (CurrentProjectionResolution.x != ViewSettings.Projection.Resolution.x || CurrentProjectionResolution.y != ViewSettings.Projection.Resolution.y || ViewSettings.Projection.CurrentDepthQuality != ViewSettings.Projection.DepthQuality) {
    207.                     if (TempRenderText) {
    208.                         #if UNITY_EDITOR
    209.                             DestroyImmediate (TempRenderText, false);
    210.                         #else
    211.                             Destroy (TempRenderText);
    212.                         #endif
    213.                     } else
    214.                         TempRenderText = new RenderTexture (Convert.ToInt32 (ViewSettings.Projection.Resolution.x), Convert.ToInt32 (ViewSettings.Projection.Resolution.y), ViewSettings.Projection.DepthQuality == ViewSettingsClass.ProjectionClass.DepthQualityEnum.Fast ? 16 : 24);
    215.  
    216.                     int RenderTextsLength = 0;
    217.  
    218.                     for (int i = 0; i < RenderTexts.Length; i++) {
    219.                         if (RenderTexts [i]) {
    220.                             #if UNITY_EDITOR
    221.                                 if (!EditorApplication.isPlaying)
    222.                                     DestroyImmediate (RenderTexts [i], false);
    223.                                 if (EditorApplication.isPlaying)
    224.                                     Destroy (RenderTexts [i]);
    225.                             #else
    226.                                 Destroy (RenderTexts [i]);
    227.                             #endif
    228.                         } else {
    229.                             RenderTexts [i] = new RenderTexture (Convert.ToInt32 (ViewSettings.Projection.Resolution.x), Convert.ToInt32 (ViewSettings.Projection.Resolution.y), ViewSettings.Projection.DepthQuality == ViewSettingsClass.ProjectionClass.DepthQualityEnum.Fast ? 16 : 24);
    230.                             RenderTexts [i].name = this.gameObject.name + " RenderTexture " + i;
    231.  
    232.                             RenderTextsLength += 1;
    233.                         }
    234.                     }
    235.  
    236.                     if (RenderTextsLength == RenderTexts.Length) {
    237.                         CurrentProjectionResolution = new Vector2 (ViewSettings.Projection.Resolution.x, ViewSettings.Projection.Resolution.y);
    238.  
    239.                         ViewSettings.Projection.CurrentDepthQuality = ViewSettings.Projection.DepthQuality;
    240.                     }
    241.                 }
    242.  
    243.                 #if UNITY_EDITOR
    244.                     LayerMask SceneTabLayerMask = Tools.visibleLayers;
    245.  
    246.                     SceneTabLayerMask &= ~(1 << 1); //Disable SceneviewRender layer on Sceneview
    247.  
    248.                     Tools.visibleLayers = SceneTabLayerMask;
    249.  
    250.                     //Generate projection plane for Sceneview
    251.                     if (!SceneviewRender) {
    252.                         SceneviewRender = new GameObject (transform.name + " SceneviewRender");
    253.  
    254.                         SceneviewRender.AddComponent<MeshFilter> ();
    255.                         SceneviewRender.AddComponent<MeshRenderer> ();
    256.  
    257.                         SceneviewRender.transform.position = transform.position;
    258.                         SceneviewRender.transform.rotation = transform.rotation;
    259.                         SceneviewRender.transform.localScale = transform.localScale;
    260.                         SceneviewRender.transform.parent = transform;
    261.                     } else {
    262.                         if (SceneviewRender.name != transform.name + " SceneviewRender")
    263.                             SceneviewRender.name = transform.name + " SceneviewRender";
    264.  
    265.                         SceneviewRender.layer = 4;
    266.  
    267.                         SceneviewRender.transform.localPosition = new Vector3 (0, 0, .0001f);
    268.  
    269.                         SceneviewRender.GetComponent<MeshFilter> ().sharedMesh = PortalMesh;
    270.                         SceneviewRender.GetComponent<MeshRenderer> ().sharedMaterial = PortalMaterials [1];
    271.                        
    272.                         //Enable/Disable portal rendering by bool variable
    273.                         SceneviewRender.GetComponent<MeshRenderer> ().enabled = PortalSettings.EnableRender ? true : false;
    274.                        
    275.                         //Apply render texture to the scene portal material
    276.                         if (PortalMaterials.Length > 1)
    277.                             SceneviewRender.GetComponent<MeshRenderer> ().sharedMaterial.SetTexture ("_MainTex", InGameCamera && PairedPortal.GetComponent<PortalManager> ().RenderTexts [1] ? PairedPortal.GetComponent<PortalManager> ().RenderTexts [1] : null);
    278.                     }
    279.                 #endif
    280.  
    281.                 //Apply render texture to the game portal material
    282.                 if (PortalMaterials.Length > 0)
    283.                     GetComponent<MeshRenderer> ().sharedMaterial.SetTexture ("_MainTex", InGameCamera && PairedPortal.GetComponent<PortalManager> ().RenderTexts [0] ? PairedPortal.GetComponent<PortalManager> ().RenderTexts [0] : null);
    284.  
    285.                 //Enable/Disable portal rendering by bool variable
    286.                 GetComponent<MeshRenderer> ().enabled = PortalSettings.EnableRender ? true : false;
    287.                 //Manage distorstion pattern settings
    288.                 GetComponent<MeshRenderer> ().sharedMaterial.SetInt ("_EnableDistorsionPattern", ViewSettings.Distorsion.EnableDistorsion ? 1 : 0);
    289.                 GetComponent<MeshRenderer> ().sharedMaterial.SetTexture ("_DistorsionPattern", ViewSettings.Distorsion.Pattern);
    290.                 GetComponent<MeshRenderer> ().sharedMaterial.SetColor ("_DistorsionPatternColor", ViewSettings.Distorsion.Color);
    291.                 GetComponent<MeshRenderer> ().sharedMaterial.SetInt ("_DistorsionPatternTiling", ViewSettings.Distorsion.Tiling);
    292.                 GetComponent<MeshRenderer> ().sharedMaterial.SetFloat ("_DistorsionPatternSpeedX", -ViewSettings.Distorsion.SpeedX);
    293.                 GetComponent<MeshRenderer> ().sharedMaterial.SetFloat ("_DistorsionPatternSpeedY", -ViewSettings.Distorsion.SpeedY);
    294.  
    295.                 //Generate camera for the portal rendering
    296.                 for (int j = 0; j < PortalCamObjs.Length; j++) {
    297.                     if (j < ViewSettings.Recursion.Steps + 1) {
    298.                         if (!PortalCamObjs [j]) {
    299.                             PortalCamObjs [j] = new GameObject (transform.name + " Camera " + j);
    300.  
    301.                             PortalCamObjs [j].tag = "Untagged";
    302.  
    303.                             PortalCamObjs [j].transform.parent = transform;
    304.                             PortalCamObjs [j].AddComponent<Camera> ();
    305.                             PortalCamObjs [j].GetComponent<Camera> ().enabled = false;
    306.                             InitPortalCamObjsCullingMask [j] = PortalCamObjs [j].GetComponent<Camera> ().cullingMask;
    307.                             PortalCamObjs [j].GetComponent<Camera> ().nearClipPlane = .01f;
    308.  
    309.                             PortalCamObjs [j].AddComponent<Skybox> ();
    310.                         } else {
    311.                             if (PortalCamObjs [j].name != transform.name + " Camera " + j)
    312.                                 PortalCamObjs [j].name = transform.name + " Camera " + j;
    313.  
    314.                             if (PortalCamObjs [j].GetComponent<Camera> ().depth != InGameCamera.depth - 1)
    315.                                 PortalCamObjs [j].GetComponent<Camera> ().depth = InGameCamera.depth - 1;
    316.  
    317.                             //Acquire settings from Scene/Game camera, to apply on Portal camera
    318.                             if (InGameCamera) {
    319.                                 PortalCamObjs [j].GetComponent<Camera> ().renderingPath = InGameCamera.renderingPath;
    320.                                 PortalCamObjs [j].GetComponent<Camera> ().useOcclusionCulling = InGameCamera.useOcclusionCulling;
    321.                                 PortalCamObjs [j].GetComponent<Camera> ().allowHDR = InGameCamera.allowHDR;
    322.                                 PortalCamObjs [j].GetComponent<Camera> ().allowMSAA = InGameCamera.allowMSAA;
    323.                             }
    324.                         }
    325.  
    326.                         if (PairedPortal.GetComponent<PortalManager> ().PortalCamObjs [j])
    327.                             PairedPortal.GetComponent<PortalManager> ().PortalCamObjs [j].GetComponent<Skybox> ().material = ViewSettings.Recursion.CustomFinalStep && (j > 0 && j == ViewSettings.Recursion.Steps) ? ViewSettings.Recursion.CustomFinalStep : (!PairedPortalSkybox && (j > 0 && j == ViewSettings.Recursion.Steps) ? null : PairedPortalSkybox);
    328.                     } else {
    329.                         #if UNITY_EDITOR
    330.                             if (!EditorApplication.isPlaying)
    331.                                 DestroyImmediate (PortalCamObjs [j], false);
    332.                             if (EditorApplication.isPlaying)
    333.                                 Destroy (PortalCamObjs [j]);
    334.                         #else
    335.                             Destroy (PortalCamObjs [j]);
    336.                         #endif
    337.                     }
    338.                 }
    339.  
    340.                 //Generate mesh clip plane modificator object
    341.                 if (!ClipPlanePosObj) {
    342.                     ClipPlanePosObj = new GameObject (transform.name + " ClipPlanePosObj");
    343.  
    344.                     ClipPlanePosObj.transform.position = transform.position;
    345.                     ClipPlanePosObj.transform.rotation = transform.rotation;
    346.                     ClipPlanePosObj.transform.parent = transform;
    347.                 } else {
    348.                     ClipPlanePosObj.transform.localPosition = new Vector3 (0, 0, .005f);
    349.  
    350.                     if (ClipPlanePosObj.name != transform.name + " ClipPlanePosObj")
    351.                         ClipPlanePosObj.name = transform.name + " ClipPlanePosObj";
    352.                 }
    353.  
    354.                 gameObject.layer = 1;
    355.  
    356.                 //Apply current portal mesh to the mesh collider if exist
    357.                 if (GetComponent<MeshCollider> () && GetComponent<MeshCollider> ().sharedMesh != PortalMesh)
    358.                     GetComponent<MeshCollider> ().sharedMesh = PortalMesh;
    359.                 //Disable trigger of portal collider
    360.                 if (GetComponent<Collider> ()) {
    361.                     if (GetComponent<Collider> ().isTrigger != (InGameCamera ? true : false))
    362.                         GetComponent<Collider> ().isTrigger = InGameCamera ? (PortalSettings.EnableObjsTrigger ? true : false) : false;
    363.                 } else
    364.                     Debug.LogError ("No collider component found");
    365.  
    366.                 //Move portal cameras and render it to rendertexture
    367.                 if (PairedPortal) {
    368.                     Vector3[] PortalCamPos = new Vector3[PortalCamObjs.Length];
    369.                     Quaternion[] PortalCamRot = new Quaternion[PortalCamObjs.Length];
    370.  
    371.                     if (PairedPortal.GetComponent<PortalManager> ().PortalSettings.EnableRender) {
    372.                         for (int i = 0; i < RenderTexts.Length; i++) {
    373.                             if (RenderTexts [i]) {
    374.                                 for (int j = ViewSettings.Recursion.Steps; j >= 0; j--) {
    375.                                     if (PortalCamObjs [j]) {
    376.                                         //Move portal camera to position/rotation of Scene/Game camera
    377.                                         Camera SceneCamera = null;
    378.  
    379.                                         #if UNITY_EDITOR
    380.                                             SceneCamera = SceneView.GetAllSceneCameras ().Length > 0 ? SceneView.GetAllSceneCameras () [0] : null;
    381.                                         #endif
    382.  
    383.                                         PortalCamObjs [j].GetComponent<Camera> ().aspect = (i == 1 && SceneCamera ? SceneCamera.aspect : InGameCamera.aspect);
    384.                                         PortalCamObjs [j].GetComponent<Camera> ().fieldOfView = (i == 1 && SceneCamera ? SceneCamera.fieldOfView : InGameCamera.fieldOfView);
    385.                                         PortalCamObjs [j].GetComponent<Camera> ().farClipPlane = (i == 1 && SceneCamera ? SceneCamera.farClipPlane : InGameCamera.farClipPlane);
    386.  
    387.                                         PortalCamPos [j] = PairedPortal.transform.InverseTransformPoint (i == 1 && SceneCamera ? SceneCamera.transform.position : InGameCamera.transform.position);
    388.  
    389.                                         PortalCamPos [j].x = -PortalCamPos [j].x;
    390.                                         PortalCamPos [j].z = -PortalCamPos [j].z + j * (Vector3.Distance (transform.position, PairedPortal.transform.position) / 5);
    391.  
    392.                                         PortalCamRot [j] = Quaternion.Inverse (PairedPortal.transform.rotation) * (i == 1 && SceneCamera ? SceneCamera.transform.rotation : InGameCamera.transform.rotation);
    393.  
    394.                                         PortalCamRot [j] = Quaternion.AngleAxis (180.0f, new Vector3 (0, 1, 0)) * PortalCamRot [j];
    395.  
    396.                                         PortalCamObjs [j].transform.localPosition = PortalCamPos [j];
    397.                                         PortalCamObjs [j].transform.localRotation = PortalCamRot [j];
    398.  
    399.                                         //Render inside portal cameras to render texture
    400.                                         if (j > 0 && j == ViewSettings.Recursion.Steps)
    401.                                             PortalCamObjs [j].GetComponent<Camera> ().cullingMask = 0;
    402.                                         else {
    403.                                             PortalCamObjs [j].GetComponent<Camera> ().cullingMask = InGameCamera.cullingMask;
    404.  
    405.                                             for (int k = 0; k < PortalFunctionality.ExcludedObjsFromRender.Length; k++)
    406.                                                 if (PortalFunctionality.ExcludedObjsFromRender [k].Obj)
    407.                                                     PortalCamObjs [j].GetComponent<Camera> ().cullingMask &= ~(1 << PortalFunctionality.ExcludedObjsFromRender [k].Layer);
    408.  
    409.                                             if (i == 0)
    410.                                                 PortalCamObjs [j].GetComponent<Camera> ().cullingMask &= ~(1 << 4);
    411.                                             else
    412.                                                 PortalCamObjs [j].GetComponent<Camera> ().cullingMask &= ~(1 << 1);
    413.                                         }
    414.  
    415.                                         PortalCamObjs [j].GetComponent<Camera> ().targetTexture = TempRenderText;
    416.  
    417.                                         PortalCamObjs [j].GetComponent<Camera> ().Render ();
    418.  
    419.                                         Graphics.Blit (TempRenderText, RenderTexts [i]);
    420.  
    421.                                         PortalCamObjs [j].GetComponent<Camera> ().targetTexture = null;
    422.                                     }
    423.                                 }
    424.                             }
    425.                         }
    426.                     }
    427.                 }
    428.             }
    429.         }
    430.     }
    431.  
    432.     class InitMaterialsList { public Material[] Materials; }
    433.     private GameObject[] CollidedObjs = new GameObject[0];
    434.     private string[] CollidedObjsInitName = new string[0];
    435.     [HideInInspector] public Vector3 CollidedObjsParentPreviousFirstPos;
    436.     [HideInInspector] public Vector3 CollidedObjsParentPreviousSecondPos;
    437.     private bool AcquireNextPos;
    438.     private InitMaterialsList[] CollidedObjsInitMaterials = new InitMaterialsList[0];
    439.     private bool[] StandardObjShader = new bool[0];
    440.     private bool[] CollidedObjsAlwaysTeleport = new bool[0];
    441.     private bool[] CollidedObjsFirstTrig = new bool[0];
    442.     private float[] CollidedObjsFirstTrigDist = new float[0];
    443.     private GameObject[] ProxDetCollidedObjs = new GameObject[0];
    444.     private GameObject[] CloneCollidedObjs = new GameObject[0];
    445.     private Vector3[] CollidedObjVelocity = new Vector3[0];
    446.     private bool[] ContinueTriggerEvents = new bool[0];
    447.     [HideInInspector] public bool CollidedObjsExternalParent;
    448.     [HideInInspector] public int EnterTriggerTimes;
    449.     private bool AllowTrigger;
    450.  
    451.  
    452.  
    453.  
    454.     IEnumerator TriggerEnter(Collider collision) {
    455.         if (!bTeleporterActive) {
    456.             yield break;
    457.         }
    458.  
    459.         //EDIT TO PREVENT ROOM FROM BEING SUCCCCCCED IN
    460.         if (collision.gameObject.name.Substring(0, collision.gameObject.name.Length > 6 ? 6 : collision.gameObject.name.Length) != "Player")
    461.             yield break;
    462.  
    463.         AllowTrigger = false;
    464.  
    465.         //Disable collision with objects excluded from trigger during teleport
    466.         if (PortalFunctionality.ExcludedObjsFromTrigger.Length > 0) {
    467.             for (int i = 0; i < PortalFunctionality.ExcludedObjsFromTrigger.Length; i++) {
    468.                 if (PortalFunctionality.ExcludedObjsFromTrigger [i] && PortalFunctionality.ExcludedObjsFromTrigger [i] == collision.gameObject) {
    469.                     yield break;
    470.                 }
    471.             }
    472.         }
    473.  
    474.         if (collision.gameObject != gameObject && !collision.GetComponent<PortalManager> () && !collision.name.Contains (collision.gameObject.GetHashCode ().ToString ()) && !collision.name.Contains ("Clone"))
    475.             AllowTrigger = true;
    476.  
    477.         //Increment and partially fill the arrays elements of required object for teleport
    478.         if (AllowTrigger) {
    479.             Array.Resize (ref CollidedObjs, CollidedObjs.Length + 1);
    480.             Array.Resize (ref CollidedObjsInitName, CollidedObjsInitName.Length + 1);
    481.             Array.Resize (ref CollidedObjsInitMaterials, CollidedObjsInitMaterials.Length + 1);
    482.             Array.Resize (ref StandardObjShader, StandardObjShader.Length + 1);
    483.             Array.Resize (ref CollidedObjsAlwaysTeleport, CollidedObjsAlwaysTeleport.Length + 1);
    484.             Array.Resize (ref CollidedObjsFirstTrig, CollidedObjsFirstTrig.Length + 1);
    485.             Array.Resize (ref CollidedObjsFirstTrigDist, CollidedObjsFirstTrigDist.Length + 1);
    486.             Array.Resize (ref ProxDetCollidedObjs, ProxDetCollidedObjs.Length + 1);
    487.             Array.Resize (ref CloneCollidedObjs, CloneCollidedObjs.Length + 1);
    488.             Array.Resize (ref CollidedObjVelocity, CollidedObjVelocity.Length + 1);
    489.             Array.Resize (ref ContinueTriggerEvents, ContinueTriggerEvents.Length + 1);
    490.  
    491.             CollidedObjs [CollidedObjs.Length - 1] = collision.gameObject;
    492.             CollidedObjsInitName [CollidedObjsInitName.Length - 1] = collision.gameObject.name;
    493.             if (!collision.GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> ()) {
    494.                 if (collision.transform.childCount > 0) {
    495.                     EnterTriggerTimes = 0;
    496.  
    497.                     try {
    498.                         PairedPortal.GetComponent<PortalManager> ().EnterTriggerTimes = 0;
    499.                     } catch {
    500.                         print ("Portal pair failed ln 483 PortalManager.cs");
    501.                     }
    502.  
    503.  
    504.                     for (int j = 0; j < collision.GetComponentsInChildren<Transform> ().Length; j++)
    505.                         if (collision.GetComponentsInChildren<Transform> () [j] != collision.gameObject && collision.GetComponentsInChildren<Transform> () [j].GetComponent<Camera> ()) {
    506.                             CollidedObjsParentPreviousFirstPos = collision.GetComponentsInChildren<Transform> () [j].transform.localPosition;
    507.                             try {
    508.                                 PairedPortal.GetComponent<PortalManager> ().CollidedObjsParentPreviousFirstPos = collision.GetComponentsInChildren<Transform> () [j].transform.localPosition;
    509.                             } catch {
    510.                                 print ("Portal pair failed ln 493 PortalManager.cs");
    511.                             }
    512.  
    513.                             AcquireNextPos = true;
    514.                             try {
    515.                                 PairedPortal.GetComponent<PortalManager> ().AcquireNextPos = true;
    516.                             }catch {
    517.                                 print ("Portal pair failed ln 500 PortalManager.cs");
    518.                             }
    519.  
    520.                         }
    521.                 }
    522.                 if (!AcquireNextPos && collision.GetComponent<Camera> ()) {
    523.                     EnterTriggerTimes += 1;
    524.                     PairedPortal.GetComponent<PortalManager> ().EnterTriggerTimes += 1;
    525.  
    526.                     if (EnterTriggerTimes == 2)
    527.                         CollidedObjsExternalParent = false;
    528.                 }
    529.                 if (AcquireNextPos) {
    530.                     if (collision.transform.childCount == 0 && collision.gameObject && collision.GetComponent<Camera> ()) {
    531.                         CollidedObjsParentPreviousSecondPos = collision.transform.localPosition;
    532.                         PairedPortal.GetComponent<PortalManager> ().CollidedObjsParentPreviousSecondPos = collision.transform.localPosition;
    533.  
    534.                         AcquireNextPos = false;
    535.                         PairedPortal.GetComponent<PortalManager> ().AcquireNextPos = false;
    536.                     }
    537.                 }
    538.             }
    539.  
    540.             if (CollidedObjs [CollidedObjs.Length - 1].GetComponent<MeshRenderer> ()) {
    541.                 if (!StandardObjShader[CollidedObjs.Length - 1]) {
    542.                     if (CollidedObjs [CollidedObjs.Length - 1].GetComponent<MeshRenderer> ().sharedMaterial.shader.name != "Standard")
    543.                         Debug.LogError ("The shader of object material is not 'Standard', mesh clippping will not be possible");
    544.                     if (CollidedObjs [CollidedObjs.Length - 1].GetComponent<MeshRenderer> ().sharedMaterial.shader.name == "Standard")
    545.                         StandardObjShader[CollidedObjs.Length - 1] = true;
    546.                 }
    547.                 if (StandardObjShader[CollidedObjs.Length - 1]) {
    548.                     if (CollidedObjs [CollidedObjs.Length - 1].GetComponent<MeshRenderer> () && PortalSettings.EnableClipPlane) {
    549.                         CollidedObjsInitMaterials [CollidedObjsInitMaterials.Length - 1] = new InitMaterialsList ();
    550.  
    551.                         CollidedObjsInitMaterials [CollidedObjsInitMaterials.Length - 1].Materials = CollidedObjs [CollidedObjs.Length - 1].GetComponent<MeshRenderer> ().sharedMaterials;
    552.  
    553.                         CollidedObjs [CollidedObjs.Length - 1].GetComponent<MeshRenderer> ().sharedMaterial = ClipPlaneMaterial;
    554.                         CollidedObjs [CollidedObjs.Length - 1].GetComponent<MeshRenderer> ().sharedMaterial.CopyPropertiesFromMaterial (CollidedObjsInitMaterials [CollidedObjs.Length - 1].Materials [0]);
    555.                     }
    556.                 }
    557.             }
    558.  
    559.             ContinueTriggerEvents [ContinueTriggerEvents.Length - 1] = true;
    560.         }
    561.  
    562.         yield return null;
    563.     }
    564.  
    565.     void OnTriggerEnter (Collider collision) {
    566.         StartCoroutine (TriggerEnter(collision));
    567.     }
    568.        
    569.     private GameObject[] ObjCollidedCamObj = new GameObject[2];
    570.     private GameObject[] ObjCloneCollidedCamObj = new GameObject[2];
    571.  
    572.  
    573.  
    574.     IEnumerator TriggerStay(Collider collision) {
    575.         if (!bTeleporterActive) {
    576.             yield break;
    577.         }
    578.  
    579.         //EDIT TO PREVENT ROOM FROM BEING SUCCCCCCED IN
    580.         if (collision.gameObject.name.Substring(0, collision.gameObject.name.Length > 6 ? 6 : collision.gameObject.name.Length) != "Player")
    581.             yield break;
    582.  
    583.         if (AllowTrigger) {
    584.             //Change position/rotation of required objects for teleport, and complete the fill of remaining arrays elements
    585.             for (int i = 0; i < CollidedObjs.Length; i++) {
    586.                 if (ContinueTriggerEvents [i] && CollidedObjs [i]) {
    587.                     if (!ProxDetCollidedObjs [i]) {
    588.                         ProxDetCollidedObjs [i] = new GameObject (CollidedObjs [i].name + " Proximity Detector");
    589.  
    590.                         ProxDetCollidedObjs [i].transform.position = transform.position;
    591.                         ProxDetCollidedObjs [i].transform.rotation = transform.rotation;
    592.                         ProxDetCollidedObjs [i].transform.parent = transform;
    593.                     }
    594.                     if (ProxDetCollidedObjs [i]) {
    595.                         if (PortalMesh && ProxDetCollidedObjs [i]) {
    596.                             if (CollidedObjs [i].transform.childCount > 0) {
    597.                                 for (int j = 0; j < CollidedObjs [i].transform.GetComponentsInChildren<Transform> ().Length; j++)
    598.                                     if (CollidedObjs [i].GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> () && CollidedObjs [i].transform.GetComponentsInChildren<Transform> () [j].GetComponent<Camera> ())
    599.                                         ObjCollidedCamObj [0] = CollidedObjs [i].transform.GetComponentsInChildren<Transform> () [j].gameObject;
    600.                             }
    601.                             if (CollidedObjs [i].transform.childCount == 0)
    602.                             if (CollidedObjs [i].GetComponent<Camera> ())
    603.                                 ObjCollidedCamObj [1] = CollidedObjs [i];
    604.  
    605.                             Vector3 ProxDetCollidedObjPos = transform.InverseTransformPoint ((ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0] ? ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0].transform.position : CollidedObjs [i].transform.position));
    606.                             Vector3 ProxDetCollLimit = new Vector3 (PortalMesh.bounds.size.x / 2, PortalMesh.bounds.size.y / 2, PortalMesh.bounds.size.z / 2);
    607.  
    608.                             ProxDetCollidedObjs [i].transform.localPosition = new Vector3 (ProxDetCollidedObjPos.x > -ProxDetCollLimit.x && ProxDetCollidedObjPos.x < ProxDetCollLimit.x ? ProxDetCollidedObjPos.x : ProxDetCollidedObjs [i].transform.localPosition.x, ProxDetCollidedObjPos.y > -ProxDetCollLimit.y && ProxDetCollidedObjPos.y < ProxDetCollLimit.y ? ProxDetCollidedObjPos.y : ProxDetCollidedObjs [i].transform.localPosition.y, ProxDetCollidedObjs [i].transform.localPosition.z);
    609.  
    610.                             if (!CollidedObjsAlwaysTeleport [i]) {
    611.                                 if (!CollidedObjsFirstTrig [i]) {
    612.                                     CollidedObjsFirstTrigDist [i] = Vector3.Dot (CollidedObjs [i].transform.position - ProxDetCollidedObjs [i].transform.position, ProxDetCollidedObjs [i].transform.forward);
    613.  
    614.                                     CollidedObjsFirstTrig [i] = true;
    615.                                 }
    616.                                 if (CollidedObjsFirstTrig [i] && CollidedObjsFirstTrigDist [i] < 0) {
    617.                                     CollidedObjsAlwaysTeleport [i] = true;
    618.  
    619.                                     CollidedObjs [i].name = CollidedObjs [i].name + " " + CollidedObjs [i].GetHashCode ().ToString ();
    620.                                 }
    621.                             }
    622.                             if (CollidedObjsAlwaysTeleport [i]) {
    623.                                 if (!CloneCollidedObjs [i]) {
    624.                                     CloneCollidedObjs [i] = (GameObject)Instantiate (CollidedObjs [i], PairedPortal.transform.position, PairedPortal.transform.rotation);
    625.  
    626.                                     if (CloneCollidedObjs [i].GetComponent<AudioListener> ())
    627.                                         Destroy (CloneCollidedObjs [i].GetComponent<AudioListener> ());
    628.  
    629.                                     if (CloneCollidedObjs [i].transform.childCount > 0) {
    630.                                         for (int k = 0; k < CloneCollidedObjs [i].transform.GetComponentsInChildren<Transform> ().Length; k++) {
    631.                                             if (CloneCollidedObjs [i].transform.GetComponentsInChildren<Transform> () [k] != CloneCollidedObjs [i].transform && CloneCollidedObjs [i].transform.GetComponentsInChildren<Transform> () [k].GetComponent<MeshRenderer> ())
    632.                                                 CloneCollidedObjs [i].transform.GetComponentsInChildren<Transform> () [k].GetComponent<MeshRenderer> ().enabled = false;
    633.  
    634.                                             if (CloneCollidedObjs [i].transform.GetComponentsInChildren<Transform> () [k].GetComponent<AudioListener> ())
    635.                                                 Destroy (CloneCollidedObjs [i].transform.GetComponentsInChildren<Transform> () [k].GetComponent<AudioListener> ());
    636.  
    637.                                             if (CloneCollidedObjs [i].transform.GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> () && CloneCollidedObjs [i].transform.GetComponentsInChildren<Transform> () [k].GetComponent<Camera> ())
    638.                                                 ObjCloneCollidedCamObj [0] = CloneCollidedObjs [i].transform.GetComponentsInChildren<Transform> () [k].gameObject;
    639.                                             if (!CloneCollidedObjs [i].transform.GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> () && CloneCollidedObjs [i].transform.GetComponentsInChildren<Transform> () [k].GetComponent<Camera> ())
    640.                                                 CloneCollidedObjs [i].transform.GetComponentsInChildren<Transform> () [k].gameObject.GetComponent<Camera> ().enabled = false;
    641.                                         }
    642.                                     }
    643.                                     if (CloneCollidedObjs [i].transform.childCount == 0)
    644.                                     if (CloneCollidedObjs [i].GetComponent<Camera> ())
    645.                                         ObjCloneCollidedCamObj [1] = CloneCollidedObjs [i];
    646.  
    647.                                     if (CloneCollidedObjs [i].GetComponent<MeshRenderer> () && StandardObjShader [i]) {
    648.                                         if (PortalSettings.EnableClipPlane) {
    649.                                             CloneCollidedObjs [i].GetComponent<MeshRenderer> ().sharedMaterial = CloneClipPlaneMaterial;
    650.                                             CloneCollidedObjs [i].GetComponent<MeshRenderer> ().sharedMaterial.CopyPropertiesFromMaterial (CollidedObjsInitMaterials [i].Materials [0]);
    651.                                         }
    652.                                         if (!PortalSettings.EnableClipPlane) {
    653.                                             CollidedObjs [i].GetComponent<MeshRenderer> ().sharedMaterials = CollidedObjsInitMaterials [i].Materials;
    654.                                             CloneCollidedObjs [i].GetComponent<MeshRenderer> ().sharedMaterials = CollidedObjsInitMaterials [i].Materials;
    655.                                         }
    656.                                     }
    657.  
    658.                                     if (ObjCloneCollidedCamObj [0]) {
    659.                                         CloneCollidedObjs [i].GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> ().enabled = false;
    660.  
    661.                                         CloneCollidedObjs [i].GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> ().m_OriginalCameraPosition = CollidedObjs [i].GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> ().m_OriginalCameraPosition;
    662.                                     }
    663.  
    664.                                     CloneCollidedObjs [i].name = CollidedObjsInitName [i] + " Clone";
    665.  
    666.                                     CloneCollidedObjs [i].transform.position = PairedPortal.transform.position;
    667.                                     CloneCollidedObjs [i].transform.parent = PairedPortal.transform;
    668.                                 }
    669.                                 if (CloneCollidedObjs [i]) {
    670.                                     float DistAmount = .007f;
    671.  
    672.                                     float CollidedObjProxDetDistStay = Vector3.Dot ((ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0] ? ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0].transform.position : CollidedObjs [i].transform.position) - ProxDetCollidedObjs [i].transform.position, ProxDetCollidedObjs [i].transform.forward);
    673.                                     Vector3 CloneCollidedObjLocalPos = transform.InverseTransformPoint (CollidedObjs [i].transform.position);
    674.  
    675.                                     CloneCollidedObjLocalPos.x = -CloneCollidedObjLocalPos.x;
    676.                                     CloneCollidedObjLocalPos.z = -CloneCollidedObjLocalPos.z - DistAmount;
    677.  
    678.                                     CloneCollidedObjs [i].transform.localPosition = CloneCollidedObjLocalPos;
    679.  
    680.                                     Quaternion CloneCollidedObjLocalRot = Quaternion.Inverse (transform.rotation) * (CollidedObjs [i].transform.rotation);
    681.  
    682.                                     CloneCollidedObjLocalRot = Quaternion.AngleAxis (180.0f, new Vector3 (0, -1, 0)) * CloneCollidedObjLocalRot;
    683.  
    684.                                     CloneCollidedObjs [i].transform.localRotation = CloneCollidedObjLocalRot;
    685.  
    686.                                     if (ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0] && ObjCloneCollidedCamObj [ObjCloneCollidedCamObj [1] ? 1 : 0]) {
    687.                                         if (!ObjCloneCollidedCamObj [ObjCloneCollidedCamObj [1] ? 1 : 0].GetComponent<Skybox> ())
    688.                                             ObjCloneCollidedCamObj [ObjCloneCollidedCamObj [1] ? 1 : 0].AddComponent<Skybox> ();
    689.                                         if (ObjCloneCollidedCamObj [ObjCloneCollidedCamObj [1] ? 1 : 0].GetComponent<Skybox> ()) {
    690.                                             ObjCloneCollidedCamObj [ObjCloneCollidedCamObj [1] ? 1 : 0].GetComponent<Skybox> ().material = PairedPortalSkybox;
    691.  
    692.                                             if (!PairedPortalSkybox) {
    693.                                                 #if UNITY_EDITOR
    694.                                                 if (!EditorApplication.isPlaying)
    695.                                                     DestroyImmediate (ObjCloneCollidedCamObj [ObjCloneCollidedCamObj [1] ? 1 : 0].GetComponent<Skybox> (), false);
    696.                                                 if (EditorApplication.isPlaying)
    697.                                                     Destroy (ObjCloneCollidedCamObj [ObjCloneCollidedCamObj [1] ? 1 : 0].GetComponent<Skybox> ());
    698.                                                 #else
    699.                                                 Destroy (ObjCloneCollidedCamObj [ObjCloneCollidedCamObj [1] ? 1 : 0].GetComponent<Skybox> ());
    700.                                                 #endif
    701.                                             }
    702.                                         }
    703.  
    704.                                         ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0].GetComponent<Camera> ().enabled = CollidedObjProxDetDistStay < -DistAmount ? true : false;
    705.                                         ObjCloneCollidedCamObj [ObjCloneCollidedCamObj [1] ? 1 : 0].GetComponent<Camera> ().enabled = CollidedObjProxDetDistStay >= -DistAmount ? true : false;
    706.  
    707.                                         InGameCamera = ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0].GetComponent<Camera> ().enabled ? ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0].GetComponent<Camera> () : ObjCloneCollidedCamObj [ObjCloneCollidedCamObj [1] ? 1 : 0].GetComponent<Camera> ();
    708.  
    709.                                         if (ObjCloneCollidedCamObj [0]) {
    710.                                             ObjCloneCollidedCamObj [0].transform.localPosition = ObjCollidedCamObj [0].transform.localPosition;
    711.                                             ObjCloneCollidedCamObj [0].transform.localRotation = ObjCollidedCamObj [0].transform.localRotation;
    712.                                         }
    713.                                     }
    714.  
    715.                                     if (CollidedObjs [i].GetComponent<MeshRenderer> () && CollidedObjs [i].GetComponent<MeshRenderer> ().sharedMaterial == ClipPlaneMaterial) {
    716.                                         Vector3 DirectionVector = Vector3.forward;
    717.  
    718.                                         CollidedObjs [i].GetComponent<MeshRenderer> ().sharedMaterial.SetVector ("_PlanePoint", ClipPlanePosObj.transform.position);
    719.                                         CollidedObjs [i].GetComponent<MeshRenderer> ().sharedMaterial.SetVector ("_PlaneNormal", Quaternion.Euler (transform.eulerAngles) * -DirectionVector);
    720.  
    721.                                         CloneCollidedObjs [i].GetComponent<MeshRenderer> ().sharedMaterial.SetVector ("_PlanePoint", PairedPortal.GetComponent<PortalManager> ().ClipPlanePosObj.transform.position);
    722.                                         CloneCollidedObjs [i].GetComponent<MeshRenderer> ().sharedMaterial.SetVector ("_PlaneNormal", Quaternion.Euler (PairedPortal.transform.eulerAngles) * -DirectionVector);
    723.                                     }
    724.                                 }
    725.                             }
    726.                         }
    727.                     }
    728.                 }
    729.             }
    730.         }
    731.  
    732.         yield return null;
    733.    
    734.     }
    735.  
    736.  
    737.     void OnTriggerStay (Collider collision) {
    738.         StartCoroutine (TriggerStay (collision));
    739.     }
    740.  
    741.  
    742.  
    743.  
    744.  
    745.  
    746.  
    747.     private Vector3 PreviousCollidedObjsInternalParentPos;
    748.  
    749.  
    750.  
    751.  
    752.     IEnumerator TriggerExit(Collider collision) {
    753.         if (!bTeleporterActive) {
    754.             yield break;
    755.         }
    756.  
    757.         //EDIT TO PREVENT ROOM FROM BEING SUCCCCCCED IN
    758.         if (collision.gameObject.name.Substring(0, collision.gameObject.name.Length > 6 ? 6 : collision.gameObject.name.Length) != "Player")
    759.             yield break;
    760.  
    761.         if (AllowTrigger) {
    762.             //Destroy required objects for teleport, reset relative arrays, and move original collided object to the its final position/rotation
    763.             for (int i = 0; i < CloneCollidedObjs.Length; i++) {
    764.                 if (ContinueTriggerEvents [i] && CollidedObjs [i] && CollidedObjs [i].GetHashCode ().ToString () == collision.gameObject.GetHashCode ().ToString () && CloneCollidedObjs [i]) {
    765.                     if (CollidedObjVelocity [i] == Vector3.zero)
    766.                         CollidedObjVelocity [i] = CollidedObjs [i].GetComponent<Rigidbody> () ? CollidedObjs [i].GetComponent<Rigidbody> ().velocity.magnitude * -PairedPortal.transform.forward : new Vector3 (0, 0, 0);
    767.  
    768.                     float CollObjProxDetDistExit = Vector3.Dot (CollidedObjs [i].transform.position - ProxDetCollidedObjs [i].transform.position, ProxDetCollidedObjs [i].transform.forward);
    769.  
    770.                     GameObject[] CollidedObjsInternalParent = new GameObject[CollidedObjs [i].transform.childCount > 0 && !CollidedObjs [i].GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> () ? CollidedObjs [i].transform.childCount : 0];
    771.  
    772.                     if (CollidedObjsInternalParent.Length > 0) {
    773.                         for (int j = 0; j < CollidedObjs [i].transform.GetComponentsInChildren<Transform> ().Length; j++) {
    774.                             if (CollidedObjs [i].transform.GetComponentsInChildren<Transform> () [j] != CollidedObjs [i].transform && CollidedObjs [i].transform.GetComponentsInChildren<Transform> () [j].GetComponent<Camera> ()) {
    775.                                 CollidedObjsInternalParent [0] = CollidedObjs [i].transform.GetComponentsInChildren<Transform> () [j].gameObject;
    776.                                 PreviousCollidedObjsInternalParentPos = CollidedObjsInternalParent [0].transform.position;
    777.                             }
    778.                         }
    779.                     }
    780.  
    781.                     if (CollidedObjs [i].transform.childCount > 0) {
    782.                         for (int k = 0; k < CollidedObjs [i].transform.GetComponentsInChildren<Transform> ().Length; k++)
    783.                             if (CollidedObjs [i].GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> () && CollidedObjs [i].transform.GetComponentsInChildren<Transform> () [k].GetComponent<Camera> ())
    784.                                 ObjCollidedCamObj [0] = CollidedObjs [i].transform.GetComponentsInChildren<Transform> () [k].gameObject;
    785.                     }
    786.                     if (CollidedObjs [i].transform.childCount == 0)
    787.                     if (CollidedObjs [i].GetComponent<Camera> ())
    788.                         ObjCollidedCamObj [1] = CollidedObjs [i];
    789.                     if (CloneCollidedObjs [i].transform.childCount > 0) {
    790.                         for (int k = 0; k < CloneCollidedObjs [i].transform.GetComponentsInChildren<Transform> ().Length; k++)
    791.                             if (CloneCollidedObjs [i].GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> () && CloneCollidedObjs [i].transform.GetComponentsInChildren<Transform> () [k].GetComponent<Camera> ())
    792.                                 ObjCloneCollidedCamObj [0] = CloneCollidedObjs [i].transform.GetComponentsInChildren<Transform> () [k].gameObject;
    793.                     }
    794.                     if (CloneCollidedObjs [i].transform.childCount == 0)
    795.                     if (CloneCollidedObjs [i].GetComponent<Camera> ())
    796.                         ObjCloneCollidedCamObj [1] = CloneCollidedObjs [i];
    797.  
    798.                     if (CollObjProxDetDistExit > 0) {
    799.                         if (!CollidedObjs [i].GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> ()) {
    800.                             if (CollidedObjsInternalParent.Length == 0) {
    801.                                 if (CollidedObjs [i].transform.parent != null) {
    802.                                     if (!CollidedObjsExternalParent)
    803.                                         CollidedObjs [i].transform.localPosition = CollidedObjsParentPreviousFirstPos;
    804.                                     if (CollidedObjsExternalParent)
    805.                                         CollidedObjs [i].transform.localPosition = CollidedObjsParentPreviousSecondPos;
    806.                                 }
    807.                                 if (CollidedObjs [i].transform.parent == null)
    808.                                     CollidedObjs [i].transform.position = CloneCollidedObjs [i].transform.position;
    809.                             }
    810.                             if (CollidedObjsInternalParent.Length > 0) {
    811.                                 CollidedObjs [i].transform.position = CloneCollidedObjs [i].transform.position;
    812.  
    813.                                 CollidedObjsInternalParent [0].transform.position = PreviousCollidedObjsInternalParentPos;
    814.                             }
    815.                         }
    816.  
    817.                         bool CollidedObjFPS = CollidedObjs [i].GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> ();
    818.  
    819.                         if (CollidedObjFPS)
    820.                             CollidedObjs [i].GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> ().m_MouseLook.Init (CollidedObjs [i].transform, CollidedObjs [i].GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> ().m_Camera.transform);
    821.  
    822.                         if (ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0] && ObjCloneCollidedCamObj [ObjCloneCollidedCamObj [1] ? 1 : 0]) {
    823.                             if (PairedPortalSkybox && ObjCloneCollidedCamObj [ObjCloneCollidedCamObj [1] ? 1 : 0].GetComponent<Skybox> () && !ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0].GetComponent<Skybox> ())
    824.                                 ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0].AddComponent<Skybox> ();
    825.                             if (ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0].GetComponent<Skybox> ())
    826.                                 ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0].GetComponent<Skybox> ().material = PairedPortalSkybox;
    827.  
    828.                             ObjCollidedCamObj [ObjCollidedCamObj [1] ? 1 : 0].GetComponent<Camera> ().enabled = true;
    829.  
    830.                             if (PortalFunctionality.SceneAsyncLoad.Enable)
    831.                                 StartCoroutine ("LoadNextScene");
    832.                         }
    833.                         if (CollidedObjFPS)
    834.                             CollidedObjs [i].transform.position = CloneCollidedObjs [i].transform.position;
    835.                         CollidedObjs [i].transform.rotation = CloneCollidedObjs [i].transform.rotation;
    836.  
    837.                         if (CollidedObjVelocity [i] != new Vector3 (0, 0, 0))
    838.                             CollidedObjs [i].GetComponent<Rigidbody> ().velocity = CollidedObjVelocity [i];
    839.                     }
    840.  
    841.                     CollidedObjs [i].name = CollidedObjsInitName [i];
    842.  
    843.                     if (CollidedObjs [i].GetComponent<MeshRenderer> () && PortalSettings.EnableClipPlane && StandardObjShader [i]) {
    844.                         CollidedObjs [i].GetComponent<MeshRenderer> ().sharedMaterials = CollidedObjsInitMaterials [i].Materials;
    845.  
    846.                         CollidedObjsInitMaterials [i].Materials = null;
    847.                     }
    848.  
    849.                     CollidedObjs [i] = null;
    850.                     CollidedObjsInitName [i] = "";
    851.                     CollidedObjsAlwaysTeleport [i] = false;
    852.                     CollidedObjsFirstTrig [i] = false;
    853.                     CollidedObjsFirstTrigDist [i] = 0;
    854.                     Destroy (ProxDetCollidedObjs [i]);
    855.                     Destroy (CloneCollidedObjs [i]);
    856.                     CollidedObjVelocity [i] = new Vector3 (0, 0, 0);
    857.                     ContinueTriggerEvents [i] = false;
    858.                 }
    859.             }
    860.  
    861.             if (collision.transform.childCount == 0 && collision.GetComponent<Camera> ()) {
    862.                 CollidedObjsExternalParent = true;
    863.                 PairedPortal.GetComponent<PortalManager> ().CollidedObjsExternalParent = true;
    864.             }
    865.             if (collision.transform.childCount > 0 && !collision.GetComponent<Camera> ()) {
    866.                 CollidedObjsExternalParent = false;
    867.                 PairedPortal.GetComponent<PortalManager> ().CollidedObjsExternalParent = false;
    868.             }
    869.  
    870.             ResetVars (true);
    871.         }
    872.  
    873.         yield return null;
    874.     }
    875.  
    876.     void OnTriggerExit (Collider collision) {
    877.         StartCoroutine (TriggerExit (collision));
    878.     }
    879.  
    880.     void ResetVars (bool TriggerExit) {
    881.         bool SetVars = false;
    882.  
    883.         if (CollidedObjs.Length > 0) {
    884.             if (!TriggerExit) {
    885.                 for (int i = 0; i < CollidedObjs.Length; i++) {
    886.                     if (CloneCollidedObjs [i])
    887.                         Destroy (CloneCollidedObjs [i]);
    888.  
    889.                     if (ProxDetCollidedObjs [i])
    890.                         Destroy (ProxDetCollidedObjs [i]);
    891.  
    892.                     if (CollidedObjs [i] && CollidedObjs [i].transform.childCount > 0 && CollidedObjs [i].GetComponent<UnityStandardAssets.Characters.FirstPerson.FirstPersonController> ()) {
    893.                         Camera CollObjCam = null;
    894.  
    895.                         for (int j = 0; j < CollidedObjs [i].transform.GetComponentsInChildren<Transform> ().Length; j++)
    896.                             if (CollidedObjs [i].transform.GetComponentsInChildren<Transform> () [j].GetComponent<Camera>())
    897.                                 CollObjCam = CollidedObjs [i].transform.GetComponentsInChildren<Transform> () [j].GetComponent<Camera> ();
    898.  
    899.                         if (CollObjCam && !CollObjCam.enabled)
    900.                             CollObjCam.enabled = true;
    901.                     }
    902.                 }
    903.  
    904.                 SetVars = true;
    905.             }
    906.             if (TriggerExit) {
    907.                 int ElementsChecked = 0;
    908.  
    909.                 for (int i = 0; i < CollidedObjs.Length; i++)
    910.                     if (!CollidedObjs [i])
    911.                         ElementsChecked += 1;
    912.  
    913.                 if (ElementsChecked == CollidedObjs.Length)
    914.                     SetVars = true;
    915.  
    916.                 ElementsChecked = 0;
    917.             }
    918.         }
    919.  
    920.         if (SetVars) {
    921.             CollidedObjs = new GameObject[0];
    922.             CollidedObjsInitName = new string[0];
    923.             CollidedObjsInitMaterials = new InitMaterialsList[0];
    924.             CollidedObjsAlwaysTeleport = new bool[0];
    925.             CollidedObjsFirstTrig = new bool[0];
    926.             CollidedObjsFirstTrigDist = new float[0];
    927.             ProxDetCollidedObjs = new GameObject[0];
    928.             CloneCollidedObjs = new GameObject[0];
    929.             CollidedObjVelocity = new Vector3[0];
    930.             ContinueTriggerEvents = new bool[0];
    931.         }
    932.     }
    933.  
    934.     IEnumerator LoadNextScene() {
    935.         AsyncOperation AsyncLoad = SceneManager.LoadSceneAsync (PortalFunctionality.SceneAsyncLoad.SceneIndex);
    936.  
    937.         yield return AsyncLoad;
    938.     }
    939. }
     
  46. boxhallowed

    boxhallowed

    Joined:
    Mar 31, 2015
    Posts:
    513
  47. Deleted User

    Deleted User

    Guest

    Now I have understand what you mean with room fact. in pratice I have checked only TriggerEnter with excluded list, but not Stay and Exit. I will check this...
     
  48. Deleted User

    Deleted User

    Guest

    Seems that is a mixed issue of time code execution, and a way that I have used to switch from original to cloned FPS Controller camera. See

    float DistAmount = .007f;

    and relative entire codes inside IF, for further info about it.

    Tips: Try to change .007 value to another (always little).
     
  49. Deleted User

    Deleted User

    Guest

    At least it's all free :D
     
  50. Deleted User

    Deleted User

    Guest

    I know...Unfortunately when these problems do not occur on my test machine, it is not easy for me to get a result :(

    And a complex asset like this, obtain a great benefit from free of use.