Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Futurerobot · Jul 08, 2011 at 04:23 PM · sendmessageanimationevent

Is it possible to send AnimationEvents to other gameObjects?

My characters have a setup where I use an empty GameObject as a parent, with the actual model and animations as a child. The scripts controlling the character are applied to the parent, so that I can easily replace the visuals without having to recreate the entire setup.

However this gives me a problem when using animations with animation events. They seem to default to send messages to the object containing the animation component, and I can't seem to find a way to send them to the parent object which actually contains the functions being called. Is there a smooth way to do this? Or do I have to add all the functions to a script on the object with the animations, that in turn pass them on to the parent object.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by burtonposey · Feb 02, 2016 at 05:36 AM

I know this is a really old question, but since it turned up at the top of the search results when I was reapproaching this same problem (and forgot my own solution for it from a few years back), I'd figure I'd chime in.

What I do is I have a class called TargetedMessage. This is a direct relationship, so I know what GameObject I'm going to be talking to. For more open ended relationships for Events, you'll need a more robust solution. But for a direct, "I know who I need to talk to when this Animation is done", you can use something like this:

 using UnityEngine;
 using System.Collections;
 
 public class TargetedMessage : MonoBehaviour
 {
     public GameObject target;
 
     public string message;
 
     public void DoTargetedMessage()
     {
         if (target != null)
         {
             target.SendMessage(message, SendMessageOptions.RequireReceiver);
         }
     }
 }

On your GameObject with the Animation on it, you can attach this script. Hook up the target, and put a string literal of the method you wish to call. Make an AnimationEvent and set the Function to DoTargetedMessage. It'll send the method call directly to your target!

I am currently using this to target my main scene transition class so when I transition out of the scene, it's dependent on a camera animation finishing it's movement. At the end of that movement, I called this method to let the scene class that we're totally done and we can load the next scene.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

I am trying to send a 2D texture to my first person controller to display on the GUI 1 Answer

SendMessage Not Working: JavaScript 1 Answer

Raycast check? 0 Answers

App in background still receive UnityPlayer.UnitySendMessage from Android plugin, normal ? 0 Answers

Send Message not working (editor?) 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges