In my game, I have about 20 triangles and have code that says when I click on a triangle, its scale changes, however this changes the scale of every single triangle and not just the single one I click on. This is the code I’m using:
if (Input.GetMouseButtonDown (0)) {
RaycastHit2D hit = Physics2D.Raycast (new Vector2(Camera.main.ScreenToWorldPoint (Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 0f);
if (hit.collider != null) {
transform.localScale = new Vector2 (-1,1);
}
}
How can I make it so that only the single triangle I clicked on will be affected?
Cheers