【发布时间】:2019-05-06 20:15:17
【问题描述】:
我目前正在创建一个简单的游戏,例如Angry Bird。所以我成功地创造了这样的东西,我目前面临一个问题,我想无限射击这只鸟,如果它撞到墙上,它应该会反弹回来,如果它再次撞到墙上,它会像无限一样反弹回来。
这是我的拍摄代码
public float force = 1300;
private void OnMouseUp()
{
// Disable IsKenematic
GetComponent<Rigidbody2D>().isKinematic = false;
// Add the Force
Vector2 dir = startPos - (Vector2)transform.position;
GetComponent<Rigidbody2D>().AddForce(dir * force);
//Remove the script (not the gameobject)
Destroy(this);
}
编辑
只是添加一个信息,我正在使用 Physics 2D 材料 摩擦力:0.8 弹力:0.45
【问题讨论】: