private void TransferHeat(float value) { // Debug.DrawRay(transform.position, Vector2.up, Color.blue); RaycastHit2D hit = Physics2D.Raycast((Vector2)transform.position + new Vector2(0f, 0.125f), Vector2.up, 0.4f, mask); if (hit.collider != null) { //Debug.Log(hit.collider.gameObject.name + " was hit by a raycast"); if (hit.collider.gameObject.tag != "MeatCell") { return; } //Debug.Log(hit.collider.gameObject.name + " was hit by a raycast"); FoodCell cell = hit.collider.GetComponent <FoodCell>(); cell.AddHeat(value); } }
private void OnTriggerStay2D(Collider2D other) { //Debug.Log(other.gameObject.name + " is Staying within " + gameObject.name); if (other.gameObject.tag == "Ingredient") { float yForce = Random.Range(minSizzleForce.y, maxSizzleForce.y); float xForce = Random.Range(minSizzleForce.x, maxSizzleForce.x); other.GetComponent <Rigidbody2D>().AddForce(new Vector2(xForce, yForce)); } if (other.gameObject.tag != "MeatCell") { return; } FoodCell cell = other.gameObject.GetComponent <FoodCell>(); cell.AddHeat(heatAmount); }