- Home /
How to trigger when an animated collider hits the player
The effect I'm trying to make it a rotating CCTV camera, when you are in its range of sight I want it to trigger.
I have a First Person Controller and a cube (CCTV Camera) then I remove its collider and add a box collider as a child that sticks out quite far being the range, (Tick is trigger), then using unity animation I make it rotate 180 degrees sweeping back and forth then add this script to either the player or the cube. I get a hit if the player is moving and therefore hits the collider. But if I'm not moving and the collider sweeps past me no hit is registered. How do I trigger the collider hitting the player rather than the player hitting the collider?
function OnTriggerEnter(hit: Collider){
Debug.Log("Hit " + hit.gameObject.tag);
}
Also while I'm asking, I'd like to pause the animation (CCTV camera) Once its triggered, then if you move away resume playing the animation. Can you please point me in the right direction to pause unity animations? Thanks :)