OnTriggerEnter not working all the time.

I am developing this faller platformer where the player is to reach the bottom while picking the right platforms to land on. There are also pickups for the player on the way down. When my player lands on the the blue plartforms they are meant to change color and the pickups and meant to deactivate when the player collides with them.

This does not work all the time. Sometimes the player will collide with the plartform or pickup and nothing will happen. Could anyone help me with this.

Here is the Trigger code below.

void OnTriggerEnter2D(Collider2D target)
	{
		if (target.tag =="Door") 

    {
			
			cameraScript.moveCamera = false;
		    DoorUI.SetActive (true);
		    
			 // Door open and stop the camera.
	}
  	

	 if (target.tag == "Coins") 
	   {    

			coinCount++;
			scoreCount += 200;
			AudioSource.PlayClipAtPoint(coinSound, target.transform.position);
			target.gameObject.SetActive (false);
			
		}
       
     if (target.tag == "Life") 
       {    
       	    
			lifeCount++;
			scoreCount += 300;
			AudioSource.PlayClipAtPoint(lifeSound, target.transform.position);
			target.gameObject.SetActive (false);
			
			
		}
		
	if (target.tag == "Boundary") 
		{   
			
			cameraScript.moveCamera = false;
			countPoints = false;
			
			CheckGameStatus();

			
		    
		}
		
	if (target.tag == "Deadly") 
		{   
			
			cameraScript.moveCamera = false;
			countPoints = false;

            
			CheckGameStatus();
				
		}
		

		


     for(int i = 0; i < listener1.Length; i++)
     {
        
		if (target.gameObject == listener1 *)*
  •    {* 
    

musicBoostCount++;

  •    	Debug.Log ("IT HAPPEND");*
    
  •   }* 
    
  • }*

  • for(int i = 0; i < listener2.Length; i++)*
    {

_ if (target.gameObject == listener2*)_
_
{*_

musicBoostCount++;
* Debug.Log (“IT HAPPEND2”);*

* }*

* }*

* if (target.tag == “Clouds”)*
* {*

* grounded = true;*

* }*

}`
Here is a Link to My Dev Blog with Gifs of the game in case anyone needs more info :
[1]
_*[1]: https://mzitodevblog.wordpress.com/2016/05/09/gameplay-gif-monday/*_

Odds are that your object is moving too fast for the trigger to be calculated, effectively being positioned over the platform one frame and below it the next. You could do 1 of 2 things

  1. Clamp the downward/y movement of the player character so it can only move so quickly
  2. Since the triggers use the physics update you could increase the frequency of the fixed timestep Unity - Manual: Time

From the gifs it looks like there is a button press or some kind of trigger that allows the player to fall quickly. Like Nodgez said the movement may be to fast to detect the collision. Another suggestion would be to use a raycast to detect the collisions. Shoot a ray out from the feet for a short distance and this will allow more than the single pixel of collision detection. Not sure if this will help or not either but there is also OnCollisionStay. OnCollisionStay should at least help with the power-ups. If You use onCollisonStay I would use it as well as CollisionEnter and have CollisionStay as a backup in case Enter doesn’t trigger. RayCast and RayCast Hit would be something to look into for the fast movement.