c# - Unity3d "Cannot implicitly convert type `void' to `bool'" -


void update ()  {     if (transform.translate((input.acceleration.x), 0, 0))      {         getcomponent<rigidbody>().addforce(vector2.right);     } } 

i using accelerator android app , doesn't seem it. can change work keydown wont work accelerator.

error:

"cannot implicitly convert type "void" "bool"

according documentation http://docs.unity3d.com/scriptreference/transform.translate.html:

transform.translate not return boolean; return type void. therefore cannot use if statement evaluate whether or not successful.

if want check see if translate happened correctly need check side effects calling transform.translate. in other words see has changed on transform , see if matches expectations.


Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -