Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question 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?