Version: 2019.4
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; } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961