void IgnoreCollision(Collision col) { Collider childCollider = col.gameObject.GetComponent <BoxCollider>().GetComponent <Collider>(); Physics.IgnoreCollision(myCollider, childCollider, true); IgnoredCollisions.Add(childCollider); isFaded = true; childCollider.transform.parent.gameObject.GetComponent <AvoidObject>().Fade(); }
void CleanIgnoredCollisions() { foreach (Collider col in IgnoredCollisions.ToArray()) { if (Vector3.Distance(transform.position, col.transform.position) > 1.2f) { Physics.IgnoreCollision(myCollider, col.GetComponent <Collider>(), false); IgnoredCollisions.Remove(col); } } }
override protected void ResolveStairs(Collision col) { bool fullStairs = CheckStairTypeByName(col.transform.parent.name); if (!fullStairs) { Physics.IgnoreCollision(myCollider, col.collider, true); IgnoredCollisions.Add(col.collider); } else { isOnStairs = true; } }
void CleanIgnoredCollisions() { foreach (Collider col in IgnoredCollisions.ToArray()) { if (Mathf.Abs(transform.position.x - col.transform.position.x) > 1.2f) { Physics.IgnoreCollision(myCollider, col, false); col.transform.parent.gameObject.GetComponent <Stair>().Unfade(); IgnoredCollisions.Remove(col); } } if (IgnoredCollisions.Count == 0) { fadeState = false; } }
void CleanIgnoredCollisions() { foreach (Collider col in IgnoredCollisions.ToArray()) { if (Mathf.Abs(transform.position.x - col.transform.position.x) > 1.2f || Vector3.Distance(transform.position, col.transform.position) > 2.0f) { Physics.IgnoreCollision(myCollider, col, false); col.transform.parent.gameObject.GetComponent <AvoidObject>().Unfade(); IgnoredCollisions.Remove(col); } } if (IgnoredCollisions.Count == 0) { isFaded = false; } }
virtual protected void ResolveStairs(Collision col) { string facing = CheckStairDirectionInName(col.transform.parent.name); bool fullStairs = CheckStairTypeByName(col.transform.parent.name); if (!isOnStairs && isOnGround && !fullStairs) { if (facing == "right" && transform.position.x > col.transform.position.x || facing == "left" && transform.position.x < col.transform.position.x) { Physics.IgnoreCollision(myCollider, col.collider, true); IgnoredCollisions.Add(col.collider); } else { isOnStairs = true; } } else { isOnStairs = true; } }
void OnCollisionEnter(Collision col) { switch (col.gameObject.tag) { case "Stairs": ResolveStairs(col); break; case "Player": //col.gameObject.GetComponent<Player> ().isDead = true; break; case "Enemy": Physics.IgnoreCollision(myCollider, col.collider, true); IgnoredCollisions.Add(col.collider); break; default: break; } // if (col.gameObject.tag == "Stairs") { // string facing = CheckStairDirectionInName(col.transform.parent.name); // bool fullStairs = CheckStairTypeByName (col.transform.parent.name); // // if (!isOnStairs && isOnGround && !fullStairs) { // if (facing == "right" && transform.position.x > col.transform.position.x || // facing == "left" && transform.position.x < col.transform.position.x) { // Physics.IgnoreCollision (myCollider, col.collider, true); // IgnoredCollisions.Add (col); // } else { // isOnStairs = true; // } // } else { // isOnStairs = true; // } // } }
void OnCollisionEnter(Collision col) { if (col.gameObject.tag == "Stairs") { string facing = CheckStairDirectionInName(col.transform.parent.name); bool fullStairs = CheckStairTypeByName(col.transform.parent.name); Vector3 colPos = col.transform.position; if (!isOnStairs && isOnGround && !fullStairs) { if (RightEvaluation(facing, colPos) || LeftEvaluation(facing, colPos) || IgnoreEvaluation(facing, colPos) || FadeEvaluation(colPos)) { Collider childCollider = col.gameObject.GetComponent <CapsuleCollider>().GetComponent <Collider>(); Physics.IgnoreCollision(myCollider, childCollider, true); childCollider.transform.parent.gameObject.GetComponent <Stair>().Fade(); IgnoredCollisions.Add(childCollider); fadeState = true; } else { isOnStairs = true; stairCount++; } } else if (isOnStairs) { // if (transform.position.y < col.transform.position.y) { // Physics.IgnoreCollision (myCollider, col.collider, true); // col.transform.parent.gameObject.GetComponent<Stair> ().Fade (); // IgnoredCollisions.Add (col); // fadeState = true; // // } else if (isFacingRight && facing == "Left") { if (isFacingRight && facing == "left") { Physics.IgnoreCollision(myCollider, col.collider, true); col.transform.parent.gameObject.GetComponent <Stair>().Fade(); IgnoredCollisions.Add(col.collider); fadeState = true; } else if (!isFacingRight && facing == "right") { Physics.IgnoreCollision(myCollider, col.collider, true); col.transform.parent.gameObject.GetComponent <Stair>().Fade(); IgnoredCollisions.Add(col.collider); fadeState = true; } else { isOnStairs = true; stairCount++; } } else { isOnStairs = true; stairCount++; } } }