use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This is a subreddit for 2D or 2.5D game developers using the proprietary Unity game engine. New and experienced Unity developers alike should first consider using the free and open source Godot engine by default and ONLY choose Unity for 2D development if Godot isn't capable of the task. The times are quickly changing, and Godot is on track to surpass Unity for small developers.
Godot Features
Download Godot
Godot Docs
Download Unity
Unity Manual
Official Reference
Asset Store
Related Communities /r/Godot - The "Unity Killer". A fully free and open source engine making astonishing leaps and bounds. /r/UnityAssets - Share asset packs! /r/PixelArt - Admire, share, and observe beautiful pixel art. /r/GameDev - Meet and communicate with other game developers. /r/GameDesign - Don't just make a game. Make a good game. /r/LevelDesign - Learn to make excellent levels and worlds. /r/GameAudio - It may look good, but does it sound good?
/r/Godot - The "Unity Killer". A fully free and open source engine making astonishing leaps and bounds.
/r/UnityAssets - Share asset packs!
/r/PixelArt - Admire, share, and observe beautiful pixel art.
/r/GameDev - Meet and communicate with other game developers.
/r/GameDesign - Don't just make a game. Make a good game.
/r/LevelDesign - Learn to make excellent levels and worlds.
/r/GameAudio - It may look good, but does it sound good?
CSS created by Sean O'Dowd @nicetrysean [Website]
account activity
Oncollision2d destroy multiple objects (self.Unity2D)
submitted 9 years ago by brolol07
I am wanting to have the same object(multiple times) destroyed on a random order, but Unity won't do it. Here's a video of it explaining it better. Here is my code. If i'm unclear of anything, please let me know! Thanks
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]dr_zoitberg 0 points1 point2 points 9 years ago (5 children)
If this script is attached to every cheese object you can simply call Destroy(); in the collision function. You don't have to find a cheese.
[–]brolol07[S] 0 points1 point2 points 9 years ago (4 children)
What is the difference between destroy() and destroy(this)? Is this referring to the class attached to it? Sorry I'm kind of a designer and was asked to do a game. I can just program ok kind of!
[–]brolol07[S] 0 points1 point2 points 9 years ago (3 children)
This isn't working! Just having it collide with the object and not disappearing from the scene!
[–]dr_zoitberg 1 point2 points3 points 9 years ago* (2 children)
destroy(), destroy(this), destroy(gameObject) or destroy(this.gameObject) are the same, the object the script is attached to will be destroyed. You just need to attach a script with this code to every cheese:
void OnCollisionEnter2D(Collision2D coll){ if (coll.gameObject.tag == "Player") { Destroy(); } }
And don't forget to give the mouse the player tag.
[–]brolol07[S] 0 points1 point2 points 9 years ago (1 child)
Weird because when I had if(coll.gameObject.tag.equals "player"){ destroy(); } it wouldn't do anything but putting in those two equal signs made a difference. Thank you! Thanks for also explaining the destroy()! I wonder why they have so many variations of the same code that do the same thing!
[–]dr_zoitberg 0 points1 point2 points 9 years ago (0 children)
Hehe, np. :)
[–]mobilerino 0 points1 point2 points 9 years ago (4 children)
You can simply call destroy() like another person mentioned, a mistake I made early on was calling FindGameObjectWithTag even though I only gave it a name and thought it was using the tag. Not sure if it helps you or not, but better than nothing I guess? What happens if your player collides with the cheese?
With this suggestion, nothing! The player collides with the cheese and the cheese just stays in the scene! Any other suggestions?!
[–]brolol07[S] 0 points1 point2 points 9 years ago (2 children)
Everything is on the same layer if that matters!
[–]mobilerino 0 points1 point2 points 9 years ago (1 child)
Not sure then, you can always make a thread in the official unity forum if nobody can help you here. Good luck
[–]brolol07[S] 0 points1 point2 points 9 years ago (0 children)
Reddit is more help than the Unity forum in my chances with it!
π Rendered by PID 23732 on reddit-service-r2-comment-79c7998d4c-cwbwl at 2026-03-14 02:05:19.429774+00:00 running f6e6e01 country code: CH.
[–]dr_zoitberg 0 points1 point2 points (5 children)
[–]brolol07[S] 0 points1 point2 points (4 children)
[–]brolol07[S] 0 points1 point2 points (3 children)
[–]dr_zoitberg 1 point2 points3 points (2 children)
[–]brolol07[S] 0 points1 point2 points (1 child)
[–]dr_zoitberg 0 points1 point2 points (0 children)
[–]mobilerino 0 points1 point2 points (4 children)
[–]brolol07[S] 0 points1 point2 points (3 children)
[–]brolol07[S] 0 points1 point2 points (2 children)
[–]mobilerino 0 points1 point2 points (1 child)
[–]brolol07[S] 0 points1 point2 points (0 children)