0

I want to controll the steering of a motorcycle by tilting a SteamVR-Controller left or right.

What I tried is:

private SteamVR_Controller.Device controller;
public Vector3 angle { get { return controller.transform.rot.eulerAngles.x; } }
public float steerInput = 0f;

void Inputs (){
steerInput = steerInput * angle;
}

I get the following Error: Cannot implicitly convert type float' toUnityEngine.Vector3'

Do you have an idea to fix it? Greetings from germany :)

1 Answers1

1

Your angle variable is a type of Vector3.

The controller.transform.rot.eulerAngles.x property is a type of float.

You get:

Error: Cannot implicitly convert type float' toUnityEngine.Vector3':

because you are tying to return controller.transform.rot.eulerAngles.x which is a float in a property that is Vector3.

Return controller.transform.rot.eulerAngles instead since eulerAngles is Vector3.

private SteamVR_Controller.Device controller;
public Vector3 angle { get { return controller.transform.rot.eulerAngles;} }
public float steerInput = 0f;

Note that the-same thing applies to the steerInput = steerInput * angle; but in reversed this time. You can't convert Vector3 to float and have to fix that too. I can't tell what exactly you are doing there but you must fix it too.

Programmer
  • 121,791
  • 22
  • 236
  • 328
  • Thanks for your answer. But this leads to the same mistake :( – Tobias Lorenz Jun 14 '17 at 12:42
  • 1
    I think that's what OP meant. I describes that in my answer. Have no idea what OP is trying to do with `steerInput = steerInput * angle;` but he's assigning wrong datatype to `steerInput`. – Programmer Jun 14 '17 at 13:34
  • Mistake is in the same line. And it would'nt solve my problem. Because I need the x rotation. In other words: The X Rotation of the controller should increase or decrease the value of steerInput. Any ideas? Seems like vector 3 and float can't be combined in this way – Tobias Lorenz Jun 14 '17 at 14:30