Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我想完全理解().velocity在<;刚体>; righbat.GetComponent().velocity=新矢量3(0f,8f,0f);_C#_Unity3d - Fatal编程技术网

C# 我想完全理解().velocity在<;刚体>; righbat.GetComponent().velocity=新矢量3(0f,8f,0f);

C# 我想完全理解().velocity在<;刚体>; righbat.GetComponent().velocity=新矢量3(0f,8f,0f);,c#,unity3d,C#,Unity3d,好吧,rightBat.GetComponent()是一种返回传递给它的组件的通用方法。在本例中,该组件是刚体。 然后,将速度属性设置为新的向量 你也可以使用 rightBat.GetComponent<Rigidbody>().velocity = new Vector3(0f, 8f, 0f); 您可以尝试用以下方式查看上面的表达式 rightBat.GetComponent<Rigidbody>().velocity = new Vector(0f, 8f, 0f

好吧,
rightBat.GetComponent()
是一种返回传递给它的组件的通用方法。在本例中,该组件是
刚体
。 然后,将
速度
属性设置为新的
向量

你也可以使用

rightBat.GetComponent<Rigidbody>().velocity = new Vector3(0f, 8f, 0f);

您可以尝试用以下方式查看上面的表达式

rightBat.GetComponent<Rigidbody>().velocity = new Vector(0f, 8f, 0f);
((rightBat.GetComponent()).velocity=foo;
或者,使用不同的分离器(这是不正确的,但在视觉上可能更清晰)

[1]rightBat。[2]GetComponent()[3]。速度=[4]新向量3();
[1] 是您的对象(游戏对象或其他组件)

[2] 是一个方法(具有泛型语法,因此是()疯狂)

[3] 是一个属性设置器
[4] 是一个记录在案的值。阅读文档,它会给你物体的速度向量(或者让你设置)?请澄清你的问题。是的,我只是不明白为什么会有()。在velocity=new vector3之前,因为
GetComponent
是一个返回
组件的方法。你应该阅读一些关于C#和编程的基本教程。
rightBat.GetComponent<Rigidbody>().velocity = new Vector(0f, 8f, 0f);
((rightBat).GetComponent<Rigidbody>()).velocity = foo;
[1]rightBat.[2]GetComponent<Rigidbody>()[3].velocity =[4] new Vector3();