Hi,
I have a point and click adventure game. I have a main character and some doors on the screen.
I want to know when the character "collides" with a door object so I can programatically do something.
I added a "Box Trimmed" collider to the door object. Under sprite settings put collider depth to 1.
I added a "Box Trimmed" collider to my player object. Under sprite settings put collider depth to 1.
All objects have 0 z position.
In the editor, both objects have box colliders with a Z size of 2 with a nice green outline on them.
I turned on Is Trigger
In my player object script I added:
void OnTriggerEnter(Collider other)
{
Debug.Log("OnTriggerEnter " + other.name);
}
I move my player through Transform.position updates in a coroutine. No physics/forces/etc.
The trigger is never called. My character can walk all over the door object.
Am I missing something? Do I have to use rigid bodies for colliders to work?
Edit:
After trying many things (raycasting) I added rigid bodies to my door and player objects.
At first they started falling (which I don't want), then I discovered IsKinematic = false which tells the physics engine not to touch my object. Now I have my triggers working with the colliders without physics, which is what I was trying to do.
It sure would have been great if:
a) The 2d toolkit documentation/tutorial had told me I had to add a rigid body to my sprite that I added a box collider too
b) The 2d toolkit when adding a box colllider saw I didn't have a rigid body and added it for me.
Maybe every other unity developer knows to do this, but I didn't.