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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -