Version: 2017.3
public bool useGravity ;

描述

控制重力是否影响该刚体。

如果设置为 false,则刚体将呈现失重状态。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Collider coll;

void Start() { coll = GetComponent<Collider>(); coll.isTrigger = true; }

// Disables gravity on all rigidbodies entering this collider. void OnTriggerEnter(Collider other) { if (other.attachedRigidbody) other.attachedRigidbody.useGravity = false; } }