- Home /
Checking for collision when spawning 2D objects
I'm very new to Unity and C#, having a background in Java and trying my best to create a game. I currently have 2 sprites as test subjects that spawn in random locations on the screen at the start of the game. I am struggling to figure out how to check for collision in Unity C#. I've researched about Physics2D.Overlap and Physics.Check and OnCollisionEnter2D method and even OnTriggerEnter2D and I just cannot wrap my head around any of the logic. How would I code to check that if one sprite is spawned, the other sprite does not spawn over it by checking if it's collision box is hitting the other sprite's collision box and picks a new place to spawn at the start of the game? Any code examples would help tremendously.
Your answer
Follow this Question
Related Questions
Respawn from falling off world! 6 Answers
unity2D colliders not working properly,,Unity2D Colliders don't seem to be working HELP PLEASE! 0 Answers
Collision reaction not working 2 Answers
How to calculate angular velocity after a collision? 0 Answers
How to avoid gameObjects with different tags being spawned in eachother? 1 Answer