Version: 2020.3
言語: 日本語
public Vector3 centerOfMass ;

説明

Transform の原点に対する質量の中心

スクリプトから重心を設定しなかった場合、リジッドボディにアタッチされているコライダー全体から、自動的に計算します。重心を任意で設定した場合、コライダーの追加や削除、スケーリング等によるトランスの変更などのリジッドボディ編集時に、重心が自動的に再計算される事はありません。自動計算による重心に戻したい場合は Rigidbody.ResetCenterOfMass を使用してください。

Setting the center of mass is often useful when simulating cars to make them more stable. A car with a lower center of mass is less likely to topple over.

注意: centerOfMass はトランスフォームの位置と回転を基準にしていますが、トランスフォームのスケールは反映されません!

// Expose center of mass to allow it to be set from
// the inspector.
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Vector3 com; public Rigidbody rb;

void Start() { rb = GetComponent<Rigidbody>(); rb.centerOfMass = com; } }