我想将我的脚本更改为 2D c# 脚本。我知道 AddExplosionForce 不是 UnityEngine.Rigidbody2D 的成员,所以我如何将其更改为 2D 脚本,并且仍然对所有方向施加相同的力。(基本上做同样的事情,但是在 2D 中)谢谢!这是我的脚本:
# pragma strict
var explosionStrength : float = 100;
function OnCollisionEnter(_other: Collision)
{
if (_other.collider.gameObject.name == "Bouncy object")
_other.rigidbody.AddExplosionForce(explosionStrength, this.transform.position,5);
}
Run Code Online (Sandbox Code Playgroud)