Search Unity

Help Wanted Animation Event Objects

Discussion in 'Animation' started by ranjansikand, Oct 4, 2021.

  1. ranjansikand


    Apr 8, 2021
    This isn't so much an issue I'm having as something I'm just a little confused about.

    I'm using a model that has some read-only animations with it. I managed to edit one of the animations; I wanted it to fire a projectile partway through the animation. I'm generally familiar with the process, but it looked a little different since I couldn't do it through the animation window.

    Anyway, I dragged a script into the object field that looks like this:
    Code (CSharp):
    1. public class ShootingScript: MonoBehaviour
    2. {
    3.   void Update()
    4.   {
    5.     if (Input.GetKeyDown"s") Shoot();
    6.   }
    8.   public void Shoot() {}
    10.   public void Die() {}
    12. }
    I wrote that code for the example, it's not my actual code.

    I didn't specify which function to call, but it successfully calls shoot and fires the projectile I wanted (even though this script isn't attached to anything). It works, so I'm not complaining, but can someone explain to me why it's working?