![](/img/trans.png)
[英]My javascript code won't push elements to my array and I can't figure out why?
[英]Why won't my character move? I can't figure out why my Rigidbody 2D won't work
我想让我的角色跳起来,但我不知道他为什么不跳。 我的代码使用了力和 Rigidbody2D。 我是 Unity 的新手,我找不到任何答案。 请帮忙?
我的物理代码:
var trump;
function Start() {
// Assigns the Rigidbody to a variable
trump = GetComponent(Rigidbody2D);
// Variable Switches:
}
function FixedUpdate() {
if (Input.GetKeyDown(KeyCode.UpArrow)) {
GetComponent.<Rigidbody2D>().AddForce(Vector2(0,20));
}
}
您在刚体上选中了“Is Kinematic”,这意味着物理不会影响 . 你有理由让它运动吗?
它不起作用,因为 Rigidody2D 被标记为运动学。 这样做会阻止所有力作用于游戏对象。 您可以在此处阅读更多相关信息: Rigidbody.isKinematic
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.