I want to do a mining action (2D) which happens only if you touch the rock (the collision) and a key being pressed but i cant do it so i am asking you all to help me.
void Update()
{
if (Input.GetButtonDown(“Dig”))
{
bool canMine = Physics2D.Raycast(transform.position, Vector2.right * direction, 0.5f, LayerMask.NameToLayer(“Minable”);
if (canMine)
{
Mine();
}
}
}
Something along those lines should be what you’re looking for.