format
typescript
Collider.attachedRigidbodyclass: Collider
description
The Rigidbody associated with the collider.
If a collider is associated with a Rigidbody, this property can be used to get the Rigidbody and perform operations related to the Rigidbody.
parameter
| param_name | type | description |
|---|
reture
| type | description |
|---|---|
Rigidbody | The Rigidbody associated with the collider. |
code example
First, create a capsule charaterController and a cube collider in the scene (as shown in the figure below), and add a CharaterController component and a BoxCollider component to them respectively. Check the "Is Trigger" property for the BoxCollider component, and set their positions to (0,0,0) and (0,2,0) respectively. Finally, attach the script to the charaterController game object. 
typeScript
class New_TypeScript
extends Component {
OnStart(): void {
Debug.Log("OnStart");
let charater = this.gameObject.GetComponent<CharacterController>(CharacterController);
charater.Move(new Vector3(0,1,0));
}
OnTriggerEnter(collider):void{
Debug.Log(collider.attacheRigidbody);
}
}