以下代码在 Unity 5.0.0p2 中似乎是错误的:
rigidbody2D.velocity.x = Input.GetAxis("Horizontal") * 10;
所以我尝试了以下代码:
GetComponent<Rigidbody2D>().velocity.x = Input.GetAxis("Horizontal") * 10;
但它仍然无法正常工作。出现如下几条错误消息。
BCE0043: Unexpected token: ).
BCE0044: expecting ), found '.'.
UCE0001: ';' expected. Insert a semicolon at the end.
我的代码有什么问题?