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
  4. Dismiss Notice

VRTK Pause Menu and Pointers.

Discussion in 'AR/VR (XR) Discussion' started by DanielOS96, Apr 3, 2018.

  1. DanielOS96

    DanielOS96

    Joined:
    Apr 3, 2018
    Posts:
    3
    My life has come to a stand still I have been locked in my uni room for 3 days trying to figure this out. Never before has there been such utter pownage by code. I am calling for help from any saint who may be able to help me.

    My goal is pretty simple. I want to have a curved bezier pointer in my game to teleport around in, then when I press the menu button I want that curved bezier pointer to turn into a straight pointer so I can make selections on the menu, simple enough.

    The way I go about doing this is I have my straight pointer and bezier pointer stored in children of my controller.
    upload_2018-4-3_19-13-37.png
    I use a script to swap between them. So when the menu is called the Game_pointer(bezier curved pointer) is turned off and the UI_pointer is activated. When un-paused the reverse happens. Now this all works fine. the menu pops up and everything is happy.

    The Issue arises when I try to alter the timescale. The streight pointer will not load. If i change the time scale to be slower it will load sometimes but about 70% of the time the line renderer will not appear correctly. When it does not load it is still in the game. it is just at position 000 and is not targeting my controller for some reason. This is hard to explain so here are some images.

    Here is an image of when the Streight pointer renderer spawn correctly.
    https://imgur.com/AgkisaH
    Here is an image of when it spawns incorrectly.
    https://imgur.com/9BfEb1V
    you can see that for some reason the script is disabled and its not following my pointer.
    If anyone has any experience in VRTK any help would be so so so so much appreciated.


    Pastebin to my menu Script.
    https://pastebin.com/Lgg981aA

    What my menu looks like.
    https://imgur.com/qot28yh

    What my controller parent looks like.
    https://imgur.com/YIW4LHW

    What my straight pointer looks like.
    https://imgur.com/fzbaksi

    What it looks like broken.
    https://imgur.com/JqzzLJ4

    What it looks like working.
    https://imgur.com/BB1Kzam
     

    Attached Files:

    unity_ARVIlab likes this.
  2. millerlyte87

    millerlyte87

    Joined:
    Oct 31, 2014
    Posts:
    6
    One year later, but there is an easy solution to this. The VRTK_BasePointerRenderer will spawn a VRTK_TransformFollow when the renderer becomes active. You can create your own class that overrides the
    CreatePointerOriginTransformFollow() method and set the FollowMoment to OnUpdate instead of OnFixedUpdate.

    Code (CSharp):
    1. using UnityEngine;
    2. using VRTK;
    3.  
    4. public class DS_VRTK_UIStraightPointerRenderer : VRTK_StraightPointerRenderer
    5. {
    6.     protected override void CreatePointerOriginTransformFollow()
    7.     {
    8.         pointerOriginTransformFollowGameObject = new GameObject(VRTK_SharedMethods.GenerateVRTKObjectName(true, gameObject.name, "BasePointerRenderer_Origin_Smoothed"));
    9.         pointerOriginTransformFollow = pointerOriginTransformFollowGameObject.AddComponent<VRTK_TransformFollow>();
    10.         pointerOriginTransformFollow.enabled = false;
    11.         pointerOriginTransformFollow.followsScale = false;
    12.        
    13.         // Set the moment to onUpdate so it is unaffected by Time.timeScale
    14.         pointerOriginTransformFollow.moment = VRTK_TransformFollow.FollowMoment.OnUpdate;
    15.     }
    16. }
    17.  
     
    FiveFingerStudios likes this.