Can a Trigger be triggered by an animated object (script)?

I have two objects, one is animated by keyframes, the second is a stationary object in the path of the first. Ultimately, I would like to affect the animation speed (or other parameters) of the first object when it enters the second object.

I set the second object as Is Trigger and attached the following script to object one:

function OnTriggerEnter(collision : Collider)
if(collision.gameObject.tag == "cube_col")
print("trigger collision");

The animation is run in the Update function of the script (also tried just running it automatically).

The second object has a tag of “cube_col”, I also tried using the name of the object too, but this didn’t work either.

What am I doing wrong? Is what I’m trying to do even possible?


It’s entirely possible.

  1. Both objects need Physics colliders (
  2. In Edit > Project Settings > Physics, the layer(s) need to be checkmarked to allow collisions (Unity - Manual: Layer-based collision detection)
  3. As you already did, the second object’s collider should be checkmarked Is Trigger.

The type of animation (or lack thereof) doesn’t affect collisions. The Physics system only concerns itself with colliders (e.g., box collider, character capsule, etc).