Rigidbodyに力を加える
void FixedUpdate()
{
Vector3 force = new Vector3 (
0.1f,
0.2f,
0.3f
);
transform.GetComponent<Rigidbody>().AddForce(
force,
ForceMode.VelocityChange
);
}
Rigidbodyに回転の力を加える
AddTorque
で回転の力を加える事ができます。
void FixedUpdate()
{
Vector3 force = new Vector3 (
0.1f,
0.2f,
0.3f
);
transform.GetComponent<Rigidbody>().AddTorque(
force,
ForceMode.Force
);
}
ForceModeについて
名前 | 概要 |
---|---|
Force | 質量を使用して、リジッドボディへ継続的な力を加えます。 |
Acceleration | その質量を無視して、リジッドボディへ継続的な加速を追加します。 |
Impulse | その質量を使用し、リジッドボディにインスタントフォースインパルスを追加します。 |
VelocityChange | 質量を無視して、リジッドボディにインスタント速度変化を追加します。 |