ExtendRealityLtd / VRTK

An example of how to use the Tilia packages to create great content with VRTK v4.
https://www.vrtk.io/
MIT License
3.69k stars 993 forks source link

Bezier Teleport Pointer displays but doesn't teleport. #217

Closed Arfenhaus closed 8 years ago

Arfenhaus commented 8 years ago

Hi again! For some reason, with zero fiddling around in the code of it, Bezier Pointer has stopped signaling teleportation. I've reimported, copied and pasted the latest revision directly into the code, still nothing. I didn't change a single line in the script, the only thing I've changed is in DropToNearestFloor in HeightAdjustTeleport, here, to disable the blink when falling to the ground (and I don't think it has anything to do Bezier pointer):

`
// if (withBlink && !rayCollidedWith.transform.GetComponent()) // { // Blink(blinkTransitionSpeed); // }

                Vector3 newPosition = new Vector3(this.transform.position.x, floorY + 0.1f, this.transform.position.z);
                SetNewPosition(newPosition, currentFloor.transform);`
thestonefox commented 8 years ago

Which example scene are you trying it in?

I've just tried the bezier pointer in 009_Controller_BezierPointer and it seemed to be teleporting ok

Arfenhaus commented 8 years ago

Yes it works in that scene in another project, yet not in my own. So that narrows it to something I did, at least.

At what point does the Bezier script send notice to the Teleport script to run it's functions? Or where would changing outside the Bezier script only affect the Bezier script?

Arfenhaus commented 8 years ago

So I downloaded the latest commits of WorldPointer, SimplePointer, and BezierPointer and replaced what I had. That got it working perfectly.

Then, related shenanigans. I tried placing a custom pointer cursor (a 2D image on a canvas paired with a transparent cube mesh), it made the cursor and pointer invisible, as well as the teleport unworkable. I deleted the custom object from the Inspector, but that didn't fix the problem. Console kept spitting out:

NullReferenceException: Object reference not set to an instance of an object VRTK.VRTK_WorldPointer.Update () (at Assets/SteamVR_Unity_Toolkit/Scripts/Abstractions/VRTK_WorldPointer.cs:104) VRTK.VRTK_BezierPointer.Update () (at Assets/SteamVR_Unity_Toolkit/Scripts/VRTK_BezierPointer.cs:51)

Now, I've narrowed this issue to my attempts to have the 2D image always facing the Player when the teleport beam is showing by accessing the custom cursor point GameObject Rigidbody and freezing X and Z constraints. If I have the commented lines enabled:

` protected override void InitPointer() { pointerCursor = (customPointerCursor ? Instantiate(customPointerCursor) : CreateCursor());

        pointerCursor.name = string.Format("[{0}]PlayerObject_WorldPointer_BezierPointer_PointerCursor", this.gameObject.name);
        pointerCursor.layer = 2;
        pointerCursor.SetActive(false);
      //pointerCursor.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationX;
      //pointerCursor.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationZ;

        curvedBeamContainer = new GameObject(string.Format("[{0}]PlayerObject_WorldPointer_BezierPointer_CurvedBeamContainer", this.gameObject.name));
        curvedBeamContainer.SetActive(false);
        curvedBeam = curvedBeamContainer.gameObject.AddComponent<CurveGenerator>();
        curvedBeam.transform.parent = null;
        curvedBeam.Create(pointerDensity, pointerCursorRadius, customPointerTracer);
        base.InitPointer();
    }`

Then everything fails. If I follow the debug log and comment out :

` protected virtual void Update() { if (activateDelayTimer > 0) { activateDelayTimer -= Time.deltaTime; }

       // if (playAreaCursor.activeSelf)
       // {
       //     UpdateCollider();
       // }
    }`

Like so in WorldPointer, teleporting works but without the beam or cursor showing. Is there a way to have a 2D image as the Bezier tip always face the player?