playMaker

Author Topic: Oculus Rift DK 2 Positional Tracker  (Read 1744 times)

OhYeahItsJosh

  • Playmaker Newbie
  • *
  • Posts: 3
Oculus Rift DK 2 Positional Tracker
« on: October 26, 2015, 02:53:03 PM »
Hey everyone,

I just got Playmaker and I was wondering if anyone has been able to access information from the positional tracker?  I have a script that currently changes player size based on whether or not they're standing up or sitting in a chair.  A friend of mine created this code to help me out:

Code: [Select]
using UnityEngine;
using UnityEngine.VR;
using System.Collections;

public class SeatedOrStanding : MonoBehaviour
{
   [Tooltip("Normalized Seated, Standing or Transitioning. 0..1 = Seated to Standing")]
   public float Standing;
   
   private float seatedY;
   
   void Start()
   {
      RecenterSeated();
   }
   
   void Update()
   {
      float y = UnityEngine.VR.InputTracking.GetLocalPosition(0).y;
      //      y = transform.localPosition.y;
      float yMaxSeated = seatedY + 0.2f;
      float yMinStanding = seatedY + 0.4f;
      float rawStanding = (y - yMaxSeated) / (yMinStanding - yMaxSeated);
      Standing = Mathf.Clamp(rawStanding, 0f, 1f);
   }
   
   public void RecenterSeated()
   {
      StartCoroutine(RecenterSeatedCoroutine());
     
   }
   
   IEnumerator RecenterSeatedCoroutine()
   {
      InputTracking.Recenter();   
      yield return new WaitForEndOfFrame();
      seatedY = InputTracking.GetLocalPosition(0).y;
      //      seatedY = transform.localPosition.y;
   }
   
}

But I can't always ask everyone for help on coding and unfortunately, I don't have a lot of time to learn C# properly.  So I picked up Playmaker in an attempt to speed up my development process.

I need to change this script though.  The way this script currently works is that once players reach a current threshold while standing up, their in game avatar grows.  What I need is for it to directly correspond to the player as they gradually move up and down?  Basically if the player stops midway while standing up, the player in game ALSO stops scaling and doesn't continue until the player physically moves again.

I've gone through some of the tutorials that Playmaker has on Youtube, but I'm not sure if there's a way to access the positional tracker in Playmaker.  Any help will be greatly appreciated.  Thanks!