Example script: Teleport Hotkeys

The example script, Teleport Hotkeys (TeleportHotkeys.cs), which allows you to set hotkeys that teleport users to another experience when pressed. 

Here is a step-by-step guide to using the script:

  1. First, download the file TeleportHotkeys.cs, found at the end of this article.
  2. In Sansar, open the My Experiences app and choose the scene you want to edit. Click the Edit Scene edit_icon_sm.png button.
  3. Once you are in edit mode, upload the file into your inventory. See Uploading and Applying Scripts for more information.
  4. Now that you have the script in your inventory, choose an object in the scene that you want to apply the script to.
  5. Select the TeleportHotkeys.cs file from your Inventory and drag the script onto any object in the scene. 
  6. Now that the script has been applied to an object, open the properties panel for the object. In the properties panel, set IsDynamic to On so that the object can trigger script events.
  7. At the bottom of the object's properties panel is a Script Settings section. Upon looking at the Script Settings section for TeleportHotkeys.cs, you will see a list of parameters which you can set for the object. Setting values on these parameters can help you set the teleport hotkey and experience destination. Here is a short guide for each parameter you can set: 

    teleportexample.png

    TeleportHotkey Designate a hotkey that will trigger the teleport script to run and transfer the user to the designated experience. You can choose from the list of keyboard and gamepad buttons below.
    Experiences Designate the name of the designated experience that you want your users to teleport to when the TeleportHotkey is triggered.
    PersonaHandle To properly direct your users to the correct experience, you must also grab the creator's Avatar ID (aka Persona Handle) from the Experience's URL.


  8. First, set a TeleportHotkey that will be used to trigger the script. You can select from a list of buttons that are available using the keyboard or gamepad below:

             
    Keyboard Buttons
    • Key_W
    • Key_A
    • Key_S
    • Key_D
    • Key_Space
    • Key_F
    • Key_1
    • Key_2
    • Key_3
    • Key_4
    • Key_5
    • Key_6
    • Key_7
    • Key_8
    • Key_9
    • Key_0
    • Key_F1
    • Key_F2
    • Key_F3
    • Key_F4
    • Key_F5
    • Key_F6
    • Key_F7
    • Key_F8
    • Key_F9
    • Key_F10
    • Key_F11
    • Key_F12
    Gamepad Buttons
    • Gamepad_DpadUp
    • Gamepad_DpadDown
    • Gamepad_DpadLeft
    • Gamepad_DpadRight
    • Gamepad_SmallLeft // Xbox: Back, PS: Select
    • Gamepad_SmallRight // Xbox: Start, PS: Start
    • Gamepad_LeftThumb
    • Gamepad_RightThumb
    • Gamepad_LeftShoulder
    • Gamepad_RightShoulder
    • Gamepad_ButtonLeft // Xbox: X, PS: Square
    • Gamepad_ButtonTop // Xbox: Y, PS: Triangle
    • Gamepad_ButtonRight // Xbox: B, PS: Circle
    • Gamepad_ButtonBottom // Xbox: A, PS: X
    • Gamepad_Extra1
    • Gamepad_Extra2


  9. To grab the experience name and Avatar ID of the experience that you want as a teleport location, go to the details page of the the experience that you want to designate. 
  10. Once you are on the experience details page, click Copy URL on the bottom left corner of the details page. This opens a new window which shows the experience's URL, where you can copy the Experience name and the creator's Avatar ID (Persona Handle) as seen below.

    teleport_target.png
    Access the experience URL to access the Avatar ID (aka Persona Handle) and Experience name.


  11. Once you have finished setting the parameters for your object, your script is ready! Save and build your scene.
  12. If you want to verify that the script is running correctly, visit the scene once it has been built.   

Creative Commons License  

This content is licensed under the terms of the Creative Commons Attribution 4.0 International License. When using this content, you must:

  • Acknowledge that the content is from the Sansar Knowledge Base.
  • Include our copyright notice: "© 2017 Linden Research, Inc."
  • Indicate that the content is licensed under the Creative Commons Attribution-Share Alike 4.0 International License.

Include the URL for, or link to, the license summary at https://creativecommons.org/licenses/by-sa/4.0/deed.hi (and, if possible, to the complete license terms at https://creativecommons.org/licenses/by-sa/4.0/legalcode.

For example:

"This work uses content from the Sansar Knowledge Base. © 2017 Linden Research, Inc. Licensed under the Creative Commons Attribution 4.0 International License (license summary available at https://creativecommons.org/licenses/by/4.0/ and complete license terms available at https://creativecommons.org/licenses/by/4.0/legalcode)." 

 

Download Link: 

Was this article helpful?
2 out of 2 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.