unity3d - What is the code to add physics to the rigidbody in unity 5.0.0p2? -
the following code seems wrong in unity 5.0.0p2:
rigidbody2d.velocity.x = input.getaxis("horizontal") * 10;
so tried following code:
getcomponent<rigidbody2d>().velocity.x = input.getaxis("horizontal") * 10;
but still not working. several error messages appear follows.
bce0043: unexpected token: ).
bce0044: expecting ), found '.'.
uce0001: ';' expected. insert semicolon @ end.
what wrong code?
your first line no longer work because rigidbody2d no longer property of monobehaviour. has been removed, have use getcomponent<rigidbody2d>()
instead.
that doesn't fix problem however. cannot update velocity
do, setting x
value. have assign full vector. copy current velocity
vector3 of own, update x
, replace whole velocity
vector.
Comments
Post a Comment