- Home /
How to enable teleport area lock in Steam VR?
Hi, I am new in Unity and Steam VR. I'm trying to make an easy escape game for my project. I found that the teleport area can choose lock or unlock for player to "walk" around in VR. However, I would like to set the teleport area lock when the player haven't open the cage door, and the area unlock when the player open the cage door.
I'm thinking of this script, but I don't know where I can put in...
if (cagedoorLock == false && cagedoorOpen == true) { locked = false; } if (cagedoorLock == false && cagedoorOpen == false) { locked = true; }
Answer by hci-assets · Jul 14, 2021 at 12:38 AM
using Valve.VR.InteractionSystem;
public class ActivatingTeleporting: MonoBehaviour
{
// assigning your teleport area, make sure marker active is not ticked
private TeleportArea teleport;
void Start() {
}
void Update() {
if (Input.GetKeyDown(KeyCode.A))
{
ActivateTeleporting();
}
if (Input.GetKeyDown(KeyCode.D))
{
DeactivateTeleporting();
}
}
public void ActivateTeleporting() {
teleport.locked = false;
}
public void DeactivateTeleporting() {
teleport.locked = true;
}
}
, using Valve.VR.InteractionSystem;
public class ActivatingTeleporting: MonoBehaviour
{
// assigning your teleport area, make sure marker active is not ticked
private TeleportArea teleport;
void Start() {
}
void Update() {
if (Input.GetKeyDown(KeyCode.A))
{
ActivateTeleporting();
}
if (Input.GetKeyDown(KeyCode.D))
{
DeactivateTeleporting();
}
}
public void ActivateTeleporting() {
teleport.locked = false;
}
public void DeactivateTeleporting() {
teleport.locked = true;
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612200527im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Steam VR touchpad to rotate object 1 Answer
How to get size in pixels of an object using SteamVR camera 0 Answers
SteamVR Interactable Scripts, enable/disable 4 Answers
Unity 3D HTC vive - Assertion failed on expression 1 Answer
How to get controller input when using the SteamVR Interaction System 2 Answers