unity3d - Cannot multiply and assign to int -
i following unity tutorial , got error in unity car game tutorial:
bce0051: operator '*' cannot used left hand side of type 'int' , right hand side of type 'boolean'.
i found these last 2 same errors in thease line of code
// these variables allow script power wheels of car. public var frontleftwheel: wheelcollider; public var frontrightwheel: wheelcollider; public var rearleftwheel: wheelcollider; public var rearrightwheel: wheelcollider; rearrightwheel.braketorque = 60 * input.getbuttondown("jump"); rearleftwheel.braketorque = 60 * input.getbuttondown("jump");
even better @general-doomer suggested:
rearrightwheel.braketorque = input.getbuttondown("jump") ? 60 : 0;
ternary operator:
rearrightwheel.braketorque = 60 * (input.getbuttondown("jump")?1:0);
Comments
Post a Comment