2

For a VR Motorcycle Game (made with unity), I need a steering, that's controlled by the SteamVR Controllers Position.

I'm looking for one of two possibilities:

  1. Move the controller forward = steer left; Move the controller backwards = steer right.

or

  1. Tilt the controller to the right = steer right; tilt the controller to the left = steer left;

Image attached


Right now, I have this input script: (the private controller variable and the commented steerinput were just a try. Didn't do it).

//private SteamVR_Controller.Device controller;
void Inputs()
{
  Speed = rigid.velocity.magnitude * 3.6f;

  //Freezing rotation by Z axis.
  transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, 0);

  //If crashed...
  if (!crashed)
  {
      if (!changingGear)
          motorInput = Input.GetAxis("Vertical");
      else
          motorInput = Mathf.Clamp(Input.GetAxis("Vertical"), -1, 0);
      steerInput = Input.GetAxis("Horizontal");
      //steerInput = controller.transform.rot.x;
  }
  else
  {
      motorInput = 0;
      steerInput = 0;
  }

  //Reverse bool
  if (motorInput < 0 && transform.InverseTransformDirection(rigid.velocity).z < 0)
      reversing = true;
  else
      reversing = false;

}

0 Answers0