Version: 2020.3

Joint2D.attachedRigidbody

切换到手册
public Rigidbody2D attachedRigidbody ;

描述

附加到 Joint2DRigidbody2D

Joint2D 会自动附加到与 Joint2D 处于相同 GameObject 上的 Rigidbody2D

另请参阅:Rigidbody2D

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Vector2 force = Vector2.up;

void Start() { // Apply a force to the rigidbody attached to the joint. GetComponent<Joint2D>().attachedRigidbody.AddForce(force); } }