Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Call external function from TeleportPoint.cs SteamVR

Discussion in 'VR' started by bdeschryver, Nov 11, 2019.

  1. bdeschryver

    bdeschryver

    Joined:
    Jun 13, 2013
    Posts:
    93
    Hey guys,

    I am so stuck on that simple one, could you help ?

    I am using SteamVR and a teleport point which is used to jump to another scene.
    I have seen in teleportpoint.cs (line 236) that you have to add some code to handle the loading of a scene.
    I would like to do that using a function in another public script attached to my Player object.
    Everytime I try to call that function, I get an error "The type or namespace 'Scene_Loader" could not be found.
    Any idea why ? Is it related to the namespace directive at the root of TeleportPoint.cs ?

    Here is the code I added :
    Code (CSharp):
    1. public void TeleportToScene()
    2.         {
    3.             if ( !string.IsNullOrEmpty( switchToScene ) )
    4.             {
    5.                
    6.                 if (!string.IsNullOrEmpty(start_position))  //a start position in the future scene is set
    7.                 {
    8.                     //set the start position in the future scene
    9.                     Debug.Log("Switching to scene : " + switchToScene + ", with start position : " + start_position);
    10.                     //SceneManager.LoadScene(switchToScene);
    11.                     GameObject.Find("Player").GetComponent<Scene_Loader>().start_player_position = start_position; //check static value of setting in scene_loader script.
    12.                    
    13.  
    Thanks !!