2015-08-25 65 views
0

我刚开始学习统一编程 - 从Eclipse移植到Android Studio。所以,我也跟着在YouTube的一些教程,但我得到一个错误这样的:Unity错误CS0119移动对象

Assets/Scripts/Move.cs(9,17): error CS0119: Expression denotes a `method group', where a `variable', `value' or `type' was expected 

我非常简单的代码:

using UnityEngine; 
using System.Collections; 

public class Move : MonoBehaviour { 
void FixedUpdate(){ 
    float moveHorizontal = Input.GetAxis ("Horizontal"); 
    float moveVertical = Input.GetAxis ("Vertical"); 
    Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); 
    GetComponent<Rigidbody>.velocity = movement; 
    } 
} 

通常的问题是与我在网上看到这个词的新构造,但我一直这样做,有什么不同,我的在线教程在这里:https://www.youtube.com/watch?t=206&v=rVSLczG1M1E是行rigidbody.velocity=movement给了我错误,所以我查了网上,并改变它,但它仍然给我这个错误。谢谢大家

回答

2

这行不正确

GetComponent<Rigidbody>.velocity = movement; 

应该用括号阅读

GetComponent<Rigidbody>().velocity = movement; 

+0

非常感谢! – DavidBalas