|
|
@ -7,13 +7,16 @@ public class blockPush : MonoBehaviour
|
|
|
|
public bool canPush = false;
|
|
|
|
public bool canPush = false;
|
|
|
|
|
|
|
|
|
|
|
|
private Rigidbody2D blockrb2d;
|
|
|
|
private Rigidbody2D blockrb2d;
|
|
|
|
|
|
|
|
private CircleCollider2D cc2d;
|
|
|
|
|
|
|
|
|
|
|
|
public float pushPower = 2.0f;
|
|
|
|
public float pushPower = 2.0f;
|
|
|
|
|
|
|
|
private float pushVar;
|
|
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
cc2d = GetComponent<CircleCollider2D>();
|
|
|
|
|
|
|
|
pushVar = pushPower;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
// Update is called once per frame
|
|
|
@ -30,12 +33,25 @@ public class blockPush : MonoBehaviour
|
|
|
|
blockrb2d = collision.collider.GetComponent<Rigidbody2D>();
|
|
|
|
blockrb2d = collision.collider.GetComponent<Rigidbody2D>();
|
|
|
|
if (GetComponent<movement>().faceRight)
|
|
|
|
if (GetComponent<movement>().faceRight)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
blockrb2d.MovePosition(new Vector2(blockrb2d.position.x + pushPower/100, blockrb2d.position.y));
|
|
|
|
blockrb2d.MovePosition(new Vector2(blockrb2d.position.x + pushVar/100, blockrb2d.position.y));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!GetComponent<movement>().faceRight)
|
|
|
|
else if (!GetComponent<movement>().faceRight)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
blockrb2d.MovePosition(new Vector2(blockrb2d.position.x - pushPower/100, blockrb2d.position.y));
|
|
|
|
blockrb2d.MovePosition(new Vector2(blockrb2d.position.x - pushVar/ 100, blockrb2d.position.y));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(collision.tag == "Block")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pushVar = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnTriggerExit2D(Collider2D collision)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pushVar = pushPower;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|