Reputation: 29
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' to
UnityEngine.Vector3'
Do you have an idea to fix it? Greetings from germany :)
Upvotes: 0
Views: 483
Reputation: 125275
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.
Upvotes: 1