|
@@ -4,6 +4,16 @@ using System.Collections;
|
|
|
[RequireComponent(typeof(SkeletonUtilityBone)), ExecuteInEditMode]
|
|
|
public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint {
|
|
|
|
|
|
+#if UNITY_4_3
|
|
|
+ public LayerMask groundMask;
|
|
|
+ public bool use2D = false;
|
|
|
+ public bool useRadius = false;
|
|
|
+ public float castRadius = 0.1f;
|
|
|
+ public float castDistance = 5f;
|
|
|
+ public float castOffset = 0;
|
|
|
+ public float groundOffset = 0;
|
|
|
+ public float adjustSpeed = 5;
|
|
|
+#else
|
|
|
[Tooltip("LayerMask for what objects to raycast against")]
|
|
|
public LayerMask groundMask;
|
|
|
[Tooltip("The 2D")]
|
|
@@ -20,6 +30,8 @@ public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint {
|
|
|
public float groundOffset = 0;
|
|
|
[Tooltip("How fast the target IK position adjusts to the ground. Use smaller values to prevent snapping")]
|
|
|
public float adjustSpeed = 5;
|
|
|
+#endif
|
|
|
+
|
|
|
|
|
|
Vector3 rayOrigin;
|
|
|
Vector3 rayDir = new Vector3(0,-1,0);
|
|
@@ -45,7 +57,12 @@ public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint {
|
|
|
RaycastHit2D hit;
|
|
|
|
|
|
if(useRadius){
|
|
|
+#if UNITY_4_3
|
|
|
+ //NOTE: Unity 4.3.x does not have CircleCast
|
|
|
+ hit = Physics2D.Raycast(rayOrigin , rayDir, castDistance + groundOffset, groundMask);
|
|
|
+#else
|
|
|
hit = Physics2D.CircleCast( rayOrigin, castRadius, rayDir, castDistance + groundOffset, groundMask );
|
|
|
+#endif
|
|
|
}
|
|
|
else{
|
|
|
hit = Physics2D.Raycast(rayOrigin , rayDir, castDistance + groundOffset, groundMask);
|