Delete a specific GameObject (with tag) on a Specific Vector2 Location
I have this code:
float sampLocationX = 0.45f;
float sampLocationY = -4.5f;
GameObject sampleBlock = GameObject.FindGameObjectWithTag("GreenBlock");
if(sampleBlock.transform.position.x == sampLocationX && sampleBlock.transform.position.y == sampLocationY)
{
Debug.Log("There it is !");
Destroy(sampleBlock);
}
else
{
Debug.Log("Nahh dude.");
}
It just says "Nahh dude" even if there's a "GreenBlock" tagged gameObject on the said location. How can I do this?
@Dranreb$$anonymous$$ing - Why are you spam$$anonymous$$g pretty much same question in 3 different threads? (https://answers.unity.com/questions/1542300/destroy-gameobject-using-tag-and-specific-location.html) (https://answers.unity.com/questions/1542386/unity-c-target-a-game-object-with-tag-on-a-specifi.html)
Don't worry this is the last one. I'm pretty much stuck and don't know what to do. I'm kinda down right now tbh.
Your answer
![](https://koobas.hobune.stream/wayback/20220612172836im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can someone tell me how to restart the scene if my player hits two objects 2 Answers
What is the most effective way to structure Card Effects in a Single Player game? 1 Answer
Multiple Sprites, One Script, Randomization 1 Answer
One large 2d grid or multiple small ones? 1 Answer
Any one help me in this script? 0 Answers