There are four things I can think of which need to happen so that OnTriggerEnter
gets called:
- The two objects’ colliders need to actually be overlapping. Just because their rendered pixels are overlapping, doesn’t mean their colliders are overlapping. This can be checked in the editor. Their colliders are indicated with a green outline in the
Scene
tab. If you don’t see anything, make sure the button labeledGizmos
is turned on. - The two objects need to be in physics layers which are set to collide with each other. You can check this in
Edit > Settings > Physics2D > Layer Collision Matrix
. - Both objects need to have Rigidbody2D components attached. Make sure these aren’t Rigidbody components, as those are for 3D physics.
- The object which contains the
OnTriggerEnter2D
event needs to haveisTrigger = true
.
Related Posts:
- Unity 5.2.2 changing Visual Studio back to MonoDevelop
- Unity Scripts edited in Visual studio don’t provide autocomplete
- How to find child of a GameObject or the script attached to child GameObject via script
- Getting mouse position in unity
- How to make the script wait/sleep in a simple way in unity
- Error : Could not load file or assembly or one of it’s dependencies
- Configuration System Failed to Initialize
- OnCollisionEnter() not working in Unity3D
- How to add a default Default.aspx to a ASP.NET Web Application Project?
- Unity cannot convert from ‘string’ to ‘int’
- Can’t add script component because the script class cannot be found?
- Visual Studio /**/ comment shortcut?
- Why should I use SerializeField?
- OnTriggerEnter not working at Unity3D
- How to jump in Unity 3d?
- Unity3d no Monobehaviour scripts in the file, or their names don’t match the file name
- “Error while trying to run project: Unable to start program”. Can run program only once. Then VS needs restart
- Unity3d restart current scene
- How to move 2D Object with WASD in Unity
- The Object you want to instantiate is null. Unity 3D
- Can’t use System.Windows.Forms
- Unity 2d jumping script
- How do I create a Shared Code project (.shproj)
- OnCollisionEnter2D not being executed?
- How do I remedy “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning?
- Unity “The associated script can not be loaded” and “Win32Exception: The system cannot find the file specified”
- Unity – Gameobject look at mouse
- Visual studio 2019 freezes when debugging
- Visual Studio: The Operation could not be completed. The parameter is incorrect
- C# – How to convert string to char?
- Error when Building Project: Error building Player because scripts have compile errors in the editor
- Unity3D. Trying to send command for object without authority
- Expression denotes a `type’, where a `variable’, `value’ or `method group’ was expected UNITY3D
- What is the purpose of the vshost.exe file?
- “A project with an Output type of Class Library cannot be started directly”
- “A project with an Output type of Class Library cannot be started directly”
- How to get relative path of a file in visual studio?
- How to make a simple popup box in Visual C#?
- How to pass data (and references) between scenes in Unity
- Receiving access denied error from Visual Studio when trying to change target framework
- Visual Studio keeps crashing
- How can we generate getters and setters in Visual Studio?
- C# Debug – cannot start debugging because the debug target is missing
- Rotate object in Unity 3D
- OnCollisionEnter is not called in unity
- The name ‘ViewBag’ does not exist in the current context – Visual Studio 2015
- Why am I getting ‘Assembly ‘*.dll’ must be strong signed in order to be marked as a prerequisite.’?
- Create html documentation for C# code
- The provider did not return a ProviderManifestToken string Entity Framework
- Where can I read the Console output in Visual Studio 2015
- “A namespace cannot directly contain members such as fields or methods”
- Unity – How to stop Play Mode in case of infinite loop?
- Go To Definition: “Cannot navigate to the symbol under the caret.”
- Is there a keyboard shortcut to maximize the Game window in Unity in Play Mode?
- How to connect to database from Unity
- How can I convert String to Int?
- Process cannot access the file because it is being used by another proess
- Convert int to string?
- C# An established connection was aborted by the software in your host machine
- Difference between virtual and abstract methods
- How to open .dll files to see what is written inside?
- ‘do…while’ vs. ‘while’
- Unable to resolve service for type while attempting to activate
- Multiple Inheritance in C#
- Wait one second in running program
- What is WebResource.axd?
- Associating enums with strings in C#
- Proper Linq where clauses
- Validation failed for one or more entities. See ‘EntityValidationErrors’ property for more details
- How to resolve this System.IO.FileNotFoundException
- What is the best way to implement a “timer”?
- SmtpException: Unable to read data from the transport connection: net_io_connectionclosed
- How can I get the application’s path in a .NET console application?
- Tree data structure in C#
- What is 0x10 in decimal?
- Member ‘
‘ cannot be accessed with an instance reference - Sequence contains no matching element
- when do you need .ascx files and how would you use them?
- How to open a new form from another form
- The entity type
is not part of the model for the current context - Recommendation for C# Matrix Library
- Deep cloning objects
- Regular expression “^[a-zA-Z]” or “[^a-zA-Z]”
- .NET graph library around?
- Input string was not in a correct format
- Verify a method call using Moq
- XmlSerializer – There was an error reflecting type
- Run Command Prompt Commands
- Cannot implicitly convert type ‘System.Collections.Generic.List< >‘ to ‘System.Collections.Generic.IList< >‘
- How can I wait for a thread to finish with .NET?
- How do I exit a WPF application programmatically?
- How to create a new object instance from a Type
- does not implement interface member
- Why am I getting an Exception with the message “Invalid setup on a non-virtual (overridable in VB) member…”?
- IF Statement multiple conditions, same statement
- What is the easiest way to handle associative array in c#?
- What does the M stand for in C# Decimal literal notation?
- Iif equivalent in C#
- Convert an array to string
- is inaccessible due to its protection level