Created
March 2, 2015 08:34
-
-
Save dilmerv/0b4a33333c5140390a92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This method goes in your character controller | |
//CharacterController.cs | |
void GlueToFloor () | |
{ | |
if (Mathf.Abs (move) > 0 || !groundHit || IM.Jump_Button ()) { | |
this.transform.GetComponent<Rigidbody2D> ().isKinematic = false; | |
} | |
else if (groundHit && Mathf.Abs (move) == 0 && !isPlatform) { | |
this.transform.GetComponent<Rigidbody2D> ().isKinematic = true; | |
} | |
} | |
//Implemented a new extension to check when character touches a platform | |
//Collision2DExtensions.cs | |
public static class Collision2DExtensions { | |
public static bool WithPlatform(this Collision2D self) { | |
return self.gameObject.tag == "Platform"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment