SpriteFactory.RigidbodyInfo.GetRigidbody
C#: TRigidbody GetRigidbody<TRigidbody> ()
JS: function GetRigidbody.<TRigidbody> () : TRigidbody
Description
Generic function. Get the rigidbody cast to a specific type. TRigidbody must be derrived from either Rigidbody or Rigidbody2D.
Example:
C#
RigidbodyInfo rigidbodyInfo = sprite.GetRigidbody("HitCollider"); // get the rigidbody from the sprite if(rigidbodyInfo.is2D) { // this is a 2D rigidbody Rigidbody2D rb2D = rigidbodyInfo.GetCollider<Rigidbody2D>(); // get the rigidbody cast to the proper type // do something } else { // this is a 3D rigidbody Rigidbody rb = rigidbodyInfo.GetCollider<Rigidbody>(); // get the rigidbody cast to the proper type // do something }