void OnCollisionStay(Collision collision) { if (collision.gameObject.GetComponent <TerrainChunk>() != null) { IsGrounded = true; } if (collision.gameObject.GetComponent <Creature>() != null) { Vector3 f = Tr.TransformDirection(Vector3.forward); Vector3 r = Tr.TransformDirection(Vector3.right); Vector3 dir = collision.gameObject.transform.position - Tr.position; float dotF = Vector3.Dot(f, dir); float dotR = Vector3.Dot(r, dir); if (dotF < 0 && dotR < 0) { //Rb.velocity = (Tr.right) * Params.BodyParam.GetSpeed(); } else if (dotF < 0 && dotR > 0) { //Rb.velocity = (-Tr.right) * Params.BodyParam.GetSpeed(); } if (dotF > 0 && dotR < 0) { //Rb.velocity = (Tr.right) * Params.BodyParam.GetSpeed(); } if (dotF > 0 && dotR > 0) { //Rb.velocity = (-Tr.right) * Params.BodyParam.GetSpeed(); } } }