小编lak*_*ing的帖子

Component.GetComponent <T>()是一个方法,在给定的上下文中无效

如果游戏中发生了某些事情,我试图关闭一个实例化预制克隆的引力.我有这个:

public class Controller : MonoBehaviour   

   public Transform randomcoin;

   private void Start()

      if ( ... ) 
          { randomcoin.GetComponent<Rigidbody>.useGravity = false; }
Run Code Online (Sandbox Code Playgroud)

这给了我这个错误:

Component.GetComponent<T>() is a method, which is not valid in the given context
Run Code Online (Sandbox Code Playgroud)

有谁知道我怎么解决这个问题?

c# unity-game-engine unity5

5
推荐指数
1
解决办法
2463
查看次数

标签 统计

c# ×1

unity-game-engine ×1

unity5 ×1