-1

I am aware that many have already posted their problems with this command. I have tried all the differen recommendations but I am still unable to get the onTriggerEnter method to work for me.

I am following a set of tutorials and the objective is to create sort of a minigame in which you, using the FirstPersonCharacter controller collect coins.

The FirstPersonCharacter has a RigifBody attached to it, Gravity is applied and it is Kinematic, the "Player" tag is applied to the object.

The coin has a a rotation script (one of the default assets), a mesh collider with the Is Trigger checkbox and the collection script. The "Coin" tag is applied to this game object and it is static.

public class collect : MonoBehaviour 
{
    private void onTriggerEnter(Collider c0ol)
    {
        Debug.Log("Registered Trigger");
    }
    private void onCollisionEnter(Collision col)
    {
        Debug.Log("Registered Collision");
    }
}

I also placed a Debug.Log() in each method to ensure that I get something returned in case a Collision or a Trigger is activated.

I run through the coins and nothing is triggered. I have tried putting a rigid body component into the coin as well, but nothing gets triggered. I am well aware that Static Trigger Collider (Coin) should sent a trigger with a Rigid Body (player) accoding to the table at the bottom of this document.

Is there anything I am missing?

Thank you in advance for your help.

AustinWBryan
  • 3,249
  • 3
  • 24
  • 42
AMP
  • 1
  • 1
  • 3
    `onTriggerEnter` needs to start with a capital `O` -> [`OnTriggerEnter`](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerEnter.html) (and the same is true for [`OnCollisionEnter`](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter.html)) – UnholySheep Jun 30 '18 at 19:12

1 Answers1

1

You need to use a capital O as in OnCollisionEnter and OnTriggerEnter.

C# is case sensitive, so foo is not the same as Foo or fOo.

This should work:

public class Collect : MonoBehaviour 
{
    private void OnTriggerEnter(Collider c0ol)
    {
        Debug.Log("Registered Trigger");
    }
    private void OnCollisionEnter(Collision col)
    {
        Debug.Log("Registered Collision");
    }
}
AustinWBryan
  • 3,249
  • 3
  • 24
  • 42