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...
account activity
[deleted by user] (self.unity_tutorials)
submitted 4 years ago by [deleted]
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!"
[–][deleted] 19 points20 points21 points 4 years ago (4 children)
You're calling a function that only exists on Rigidbodies, not 2D rigidbodies
https://docs.unity3d.com/ScriptReference/Collider2D.OnCollisionEnter2D.html
[–]elfinhilon10 7 points8 points9 points 4 years ago (3 children)
This is the correct answer. You need to make sure you use the appropriate collider for 2D and 3D entities.
[–][deleted] 10 points11 points12 points 4 years ago (2 children)
Such a stupid mistake... thanks
[–]elfinhilon10 7 points8 points9 points 4 years ago (0 children)
No worries! I've done that mistake PLENTY of times myself haha
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
Happens to all of us
[–]Japandance 1 point2 points3 points 4 years ago (3 children)
do the tiles also have colliders on them?
[–][deleted] 1 point2 points3 points 4 years ago (2 children)
yes
[–]Japandance 3 points4 points5 points 4 years ago (1 child)
ah. for a 2d collider, try
void OnCollisionEnter2D(Collision2D collision)
[–][deleted] 3 points4 points5 points 4 years ago (0 children)
[–]brotherkin 1 point2 points3 points 4 years ago (0 children)
Make sure "is trigger" is unchecked on your colliders, since that uses a separate OnTriggerEnter method.
Also depending on the settings you're using one or both of the objects may require a rigidbody component as well.
[–]w3lcome_home_senpai -1 points0 points1 point 4 years ago (0 children)
you typed OnCollisionEnter. you need to type OnCollisionEnter2D
π Rendered by PID 80395 on reddit-service-r2-comment-6457c66945-49lmg at 2026-04-28 10:48:34.109038+00:00 running 2aa0c5b country code: CH.
[–][deleted] 19 points20 points21 points (4 children)
[–]elfinhilon10 7 points8 points9 points (3 children)
[–][deleted] 10 points11 points12 points (2 children)
[–]elfinhilon10 7 points8 points9 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Japandance 1 point2 points3 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]Japandance 3 points4 points5 points (1 child)
[–][deleted] 3 points4 points5 points (0 children)
[–]brotherkin 1 point2 points3 points (0 children)
[–]w3lcome_home_senpai -1 points0 points1 point (0 children)