mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-09 08:38:43 +08:00
unity] SkeletonUtility now adds a kinematic Rigidbody2D for non-root bone boundingbox colliders.
This commit is contained in:
parent
2dc9726282
commit
fcb6e61815
@ -75,6 +75,16 @@ namespace Spine.Unity {
|
||||
|
||||
public static PolygonCollider2D AddBoundingBoxAsComponent (BoundingBoxAttachment box, Slot slot, GameObject gameObject, bool isTrigger = true) {
|
||||
if (box == null) return null;
|
||||
|
||||
if (slot.bone != slot.Skeleton.RootBone) {
|
||||
var rb = gameObject.GetComponent<Rigidbody2D>();
|
||||
if (rb == null) {
|
||||
rb = gameObject.AddComponent<Rigidbody2D>();
|
||||
rb.isKinematic = true;
|
||||
rb.gravityScale = 0;
|
||||
}
|
||||
}
|
||||
|
||||
var collider = gameObject.AddComponent<PolygonCollider2D>();
|
||||
collider.isTrigger = isTrigger;
|
||||
SetColliderPointsLocal(collider, slot, box);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user