edward mitchell (edwardlee123543)

2 answers · asked · Lesson: Animated Spike Traps · Course: Game C# Programming Bootcamp

So im trying to activate my spike trap animation when my player walks over it, but it doesnt seem to activate , the player is correctly tagged "Player" and the script appears to be correct.

  • crew

    Well it could be a few things. First, I would ensure that your OnTriggerEnter is being called properly. Add something like this 

    Debug.Log("Player entered trigger zone") 

    within the OnTriggerEnter "if statement". This will appear in the console if it's properly detecting the player entering. Note for this to work properly, it needs three things:

    • Collider 
    • Tag of "Player" on Collider object (or any tag you specify)
    • A Rigidbody (kinematic or non-kinematic)
    If all that works properly, then it's time to check the animations. First, make sure everything is spelled properly and you're using case sensitive names. If you wrote "playSpikes" for your parameter but have "PlaySpikes" for your script it won't work. Also check to see if your transitions are working properly. If you're still having issues let me know.