Commit 14dbaa34 authored by Tanner Grehawick's avatar Tanner Grehawick

working CollisionStateRefactor

parent 8c74d0fa
No preview for this file type
...@@ -33,32 +33,37 @@ public class CollisionState : MonoBehaviour { ...@@ -33,32 +33,37 @@ public class CollisionState : MonoBehaviour {
enemyHit = Physics2D.OverlapCircle(body.position + bottomPosition, collisionRadius, enemyLayer); enemyHit = Physics2D.OverlapCircle(body.position + bottomPosition, collisionRadius, enemyLayer);
} }
void OnDrawGizmosSelected() { // void OnDrawGizmosSelected() {
Gizmos.color = Color.red; // Gizmos.color = Color.red;
Vector2 pos = bottomPosition; // Vector2 pos = bottomPosition;
pos.x += transform.position.x; // pos.x += transform.position.x;
pos.y += transform.position.y; // pos.y += transform.position.y;
Gizmos.DrawWireSphere(pos, collisionRadius); // Gizmos.DrawWireSphere(pos, collisionRadius);
pos = rightPosition; // pos = rightPosition;
pos.x += transform.position.x; // pos.x += transform.position.x;
pos.y += transform.position.y; // pos.y += transform.position.y;
Gizmos.DrawWireSphere(pos, collisionRadius); // Gizmos.DrawWireSphere(pos, collisionRadius);
pos = leftPosition; // pos = leftPosition;
pos.x += transform.position.x; // pos.x += transform.position.x;
pos.y += transform.position.y; // pos.y += transform.position.y;
Gizmos.DrawWireSphere(pos, collisionRadius); // Gizmos.DrawWireSphere(pos, collisionRadius);
} // }
float lastFixedTime;
void OnCollisionStay2D(Collision2D collision) { void OnCollisionStay2D(Collision2D collision) {
if (Time.fixedTime != lastFixedTime) {
onGround = false; onGround = false;
onWallLeft = false; onWallLeft = false;
onWallRight = false; onWallRight = false;
lastFixedTime = Time.fixedTime;
}
foreach (ContactPoint2D contact in collision.contacts) { foreach (ContactPoint2D contact in collision.contacts) {
Color color = Color.white; Color color = Color.white;
Vector2 normal = contact.normal; Vector2 normal = contact.normal;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment