我有一个手臂,它工作的很好,但是,当我尝试抛出一个物体时,它不起作用。投掷物体
经过一番思考,我做出这样的:
cube.GetComponent<Rigidbody2D>().velocity = player.GetComponent<Rigidbody2D>().velocity;
而发生这种情况:
,我打算给刚体连接到手臂,但他从以重力,我试图扭转重力,但它不起作用。
我的问题是,我如何使它与手臂一起工作?
编辑:为更好地解释整个代码(这是附着在手):
void Update() {
Collider2D touch = Physics2D.OverlapCircle(touchDetect.position, 0.01f, objectLayer);
mao1.SetBool("Ligado", ligado);
if (Input.GetKey(KeyCode.LeftShift)) {
ligado = true;
} else {
ligado = false;
}
if (Input.GetKey(KeyCode.LeftShift) && touch != null && ligado == true)
{
touch.gameObject.transform.parent = this.transform;
cubo.GetComponent<Rigidbody2D>().isKinematic = true;
Physics2D.IgnoreLayerCollision(10, 12, true);
cubo.GetComponent<Rigidbody2D>().velocity = player.GetComponent<Rigidbody2D>().velocity;
}
else if (touch != null && ligado == false)
{
touch.gameObject.transform.parent = null;
cubo.GetComponent<Rigidbody2D>().isKinematic = false;
Physics2D.IgnoreLayerCollision(10, 12, false);
}
}
不幸的是,对于这个网站,这个问题太基本,一般和含糊。我真的只是在寻找基本的Unity教程。请务必检查answers.unity3d.com网站,您可以在其中询问(甚至已经是谷歌)更基本的“非常一般的启动器”问题 – Fattie