Giter Site home page Giter Site logo

kdevs / simple-unity-vr-teleporter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ijemin/simple-unity-vr-teleporter

0.0 0.0 0.0 1.6 MB

Easy to use VR-Teleporter script.

Home Page: https://assetstore.unity.com/packages/tools/input-management/simple-vr-teleport-115996

License: MIT License

C# 100.00%

simple-unity-vr-teleporter's Introduction

Unity Simple VR Teleporter

IMAGE ALT TEXT HERE

Simple Teleporter script without any plug-in or dependencies. All scripts are accessible.

  • All you need to do is :
VRTeleporter.ToggleDisplay(true);
VRTeleporter.Teleport();

Your can download managed asset from Unity Asset Store.

Quick Start

Setup

You can find 'Teleporter' Prefab on Prefabs folder.

  1. Attach Teleporter prefab as a child of game object which representing VR Hand(or position where render of path start).
  2. Asign Body Transform property with game object which you want to teleport. (example: Root of player game object)

How to control VRTeleporter

All you need to do :

  1. Get reference of VRTeleporter object.
  2. Use two public method of VRTeleporter script.

(You can check SampleVRTeleporterController.cs in Sample folder)

Public Methods

void ToggleDisplay(bool active)

  • Active and display visual.
  • Update Path Vertices.
  • Check ground position.

Once ToggleDisplay(true) is called, VRTeleporter automatically update it's arc path on every fixed update.

(This means you don't need to call ToggleDisplay(True) on every frame whild holding down button. Just calling once for Input.GetButtonDown is enough.)

Calling ToggleDisplay(false) will turn off renderer and stop updating path and ground position.

void Teleport()

  • Teleport bodyTransform to detected ground position.

Use this when player release input button. (example: Call Teleport method when Input.GetMouseButtonUp(0) is true)

Example of how to control VRTeleporter

    public VRTeleporter teleporter;
    
    void Update () {

        if(Input.GetMouseButtonDown(0))
        {
            teleporter.ToggleDisplay(true);
        }

        if(Input.GetMouseButtonUp(0))
        {
            teleporter.Teleport();
            teleporter.ToggleDisplay(false);
        }
    }

Properties of VRTeleporter

  • Position Marker : Game object used as ground position marker
  • Body Transform : Game object which will be teleported
  • Exclude Layers : Layers which you don't want to check
  • Angle : Take-off angle of arc start position
  • Strength : Factor for how far arc gonna go

Sample

You can find quick sample on Sample Scene.

  • Sample Scene use FPSController of Unity Standard Assets::Characters.
    • You need to import Character from [Assets] > [Import Package] > [Characters], to run sample scene.
  • Standard Assets is not neccessary for actual use!!

There is FPSController game object in the Sample scene. You can find Teleporter and Teleporter Controller gameObjects from FPSController's child objects.

  • Leftclick-hold will show tha path.
  • Leftclick-up will instantlty teleport player to target position.

How to modify Looks

Just modify material used by line renderer of Teleport object, and material used by mesh renderer of Marker object.

ETC

  • VRTeleprter script is accessible, you can change whatever you want.

License

MIT

simple-unity-vr-teleporter's People

Contributors

ijemin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.