Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Teleport by button press

Discussion in 'Scripting' started by habbor, Mar 13, 2019.

  1. habbor

    habbor

    Joined:
    Mar 5, 2019
    Posts:
    1
    Hi there,

    im pretty new to unity and not a kind of a programmer, so i need a little help :)

    i´ve done a simple scene with the unity 3d game kit.

    3 Objects:
    TransitionStart (prefab) (screenshot1)
    TransitionEnd (its the TransitionStart-prefab, just renamed) (screenshot2)
    a cube (screenshot3)

    When i walk with ellen into the collider of the TransitionStart prefab its teleporting her to the TransitionEnd

    Now to my problem, i want ellen only to teleport when pushing a button (E)
    i tried some things with the "interact on button"-prefab, but i didnt work.

    i made a screenshot of the seeting i use an hopes someone can give me a little hint.

    P.S. sorry for my english, its not my foreign language.

    P.P.S: i used parts of this tutorial, they say:

    Quote:
    On Trigger Enter means that the Transition only activates when the player enters the Collider and not on a key press. If you’d rather teleport only when the player presses the interact key (E), set Transition When to Interact Pressed.
    Quote End

    but there is no "Interact Pressed" (screenshot 4)
     

    Attached Files:

    • 1.PNG
      1.PNG
      File size:
      1.3 MB
      Views:
      561
    • 2.PNG
      2.PNG
      File size:
      2.1 MB
      Views:
      800
    • 3.PNG
      3.PNG
      File size:
      1.2 MB
      Views:
      481
    • 4.PNG
      4.PNG
      File size:
      98.6 KB
      Views:
      565
  2. Simpso

    Simpso

    Joined:
    Apr 20, 2015
    Posts:
    158
    You could use a bool when doing ontriggerenter.

    So when player goes into that area it sets the value teleportRegion to true.
    Then when you press e just check also that teleportRegion is true.

    Remember to set it back to false when either trigger exit or after you teleport.