• 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
0
Question by Corvec · Oct 21, 2016 at 08:51 PM · animationscript.synchronizationagentresponse

Sync animation between multiple gameobjects on trigger

Hello all, ive been trying to find a solution or perhaps phrase what im looking for better. I have three game objects. when an event triggers I simply want to remove control from all players and carry out a series of movements/animations. For example a scripted combo where Player1 walks to Enemy(regardless of where they were when event triggered), punch enemy, the enemy now plays an animation/movement to the punch and is sent towards Player2, whom then plays another attack animation of some sort.

I can't seem to wrap my head around how to get the characters in place or how to play these individual animations and ensure they play out in sync with one another. Could someone at least help me to define a definition of what it is im trying to accomplish, perhaps I could research this better if I knew exactly what this was called.

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
1

Answer by smileteam · Oct 21, 2016 at 11:41 PM

Well, this kind of thing is very simple once you break it down into pieces. I'm not entirely sure what this is for, whether it's third person, first person, topdown, etc. so I'll try to give the best answer I can with little information.

So let's try and break it down anyway :

You have three characters. Each of them has a control script, whether that's player controlled or AI controlled.
They'll have an animation/animator component, something that contains the animations you want each of them to play.
You have "Points", yes? Where the characters will start and/or move towards.

Once you know what you have and what you need, we can start doing things.

You'll have to create an animation manager of some kind, it will have references (variables) to everything involved in the animation, that would be your characters, and movement points.

You should also create an Empty Gameobject root at the position where you want Player1 to be when it's "punching" Enemy, parented to Enemy.

Once the event is triggered the manager will disable the control scripts for the characters. Using this.

All characters should now be completely still and not move.

The next step is to move Player1 towards the previously created empty gameobject which should be parented to Enemy.

Whatever movement script you are using, you can use their movement function, or if you want something even better, create a Navmesh and Navmesh Agent for the player, so when you disable the control script, Player1 can move towards Enemy using the best path possible. While they're moving, just play the run/walk animation that you normally would play, or a leap, jump, or what have you.

Repeat for Player2 of course.

When the Characters get into position, just play the animations in turn (I don't know if you're using mecanim or the old animation system, but you should just be able to "waitforseconds" and trigger the next animation if you're looking for a quick and dirty method), and it should work out fine. Of course using the manager, re-enable all the control scripts so they can all move again.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Problem with NavMesh link and animations 1 Answer

How to change motion/animation in Animator with C# script? 0 Answers

Movie Texture with Maya Animation not syncing when Paused/Played 0 Answers

Animation script 1 Answer

Can I make animations snap to a frame? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges