BCE0019: '' is not a member of 'UnityEngine.Component'的问题

看自学网上的Unity3D的视频,其中视频中的实力代码:

n.rigidbody.AddForce(fwd * 28000);

这个代码运行会出现错误:

 BCE0144: ‘UnityEngine.Component.rigidbody‘ is obsolete. Property rigidbody has been deprecated. Use GetComponent<Rigidbody>() instead. (UnityUpgradable)

 BCE0019: ‘AddForce‘ is not a member of ‘UnityEngine.Component‘

 

字面意思很容易理解,说这个rigidbody的方法已经被淘汰了,请使用GetComponent方法来代替

Unity3D第5版的写法是这样的:

n.GetComponent(Rigidbody).AddForce(fwd * 28000);

值得在强调一遍的是:Javascript代码中注意大小写!

 

学习地址:

由于平台限制,网站链接添加,如果需要学习Unity3D,请百度:我要自学网

文章来自:http://www.cnblogs.com/R0SS/p/5066866.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3