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 /
  • Help Room /
avatar image
1
Question by Skar_Universe · Feb 05, 2017 at 03:40 AM · animationshaderanimatorquicktimeminigame

Animating 2 objects in sync with separate animators without parenting

Hey guys,

So I have a player character and an enemy character both having their own animators and a bunch of animations (this is a 2D game with sprites btw) .. it all works great but now I wanted to do a God of War style mini game/ QTE. I keep wondering though how to animate them in sync. I tried making a parent object for both and putting an animator on that too but that really messes up my gameplay otherwise .. and also my whole project started collapsing .. references got removed, animations glitching ... this was when I coded in that when the mini game is triggered the parents would change for both characters but the animator doesn't read the objects properly and doen't initiate my animation. Also if a child has an animator I cant select that child in the animation window.. I have to remove the animator, animate then add the animator again.

Then I tried making them children of the parent object permanently but then realized I'd have to change my whole movement code which I prefer not to do and also doing that made all my previous animations bug out .. since the animator couldn't find the baby objects. I'm thinking of now making each of them animate separately through bools but I'm not sure if the animations will activate, blend and play at the same time in sync.

So just wondering if you guys can throw any ideas around on how this could be achieved. Thanks in advance!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Skar_Universe · Feb 06, 2017 at 03:58 AM

Ok guys I figured it out. In my case what I did is probably too complicated and there might be an easier solution out there but this totally worked for me.

So I created duplicates of both my character and removed all the colliders, scripts and anything unnecessary from the objects and their child objects. Then I parented them under a single object with a script. I constantly move the parent objects position to one of the original characters position so that I know where the new duplicates will appear.

In the script I call all the SpriteRenderers on my duplicates (rough script) .. SpriteRendered objA; void Start() { objA = GetComponentsInChildren<SpriteRenderer>(); } void FunctionName(){ if (conditionIsTrue){ foreach (SpriteRenderer s in ObjA){ s.enabled = false; } } }

do the same for second object and while re-enabling. Also, I added the code that when re-enabling the original objects I move the original objects to where the transforms of their duplicates are at the time. So it all works smoothly. If anyone else needs more info just ask.

Cheers.

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
avatar image
0

Answer by T_Lavell · Feb 05, 2017 at 11:58 PM

I'm not sure exactly how, or for how long, you want the animations to sync, but it shouldn't be too difficult to achieve if the animations themselves are compatible. Simply use the same event to trigger both animations.

For example, if I want character A and character B to both punch at the same time, I can use A.anim.SetTrigger("Punch"); and B.anim.SetTrigger("Punch"); in the same function. If the Sprite animations are the same duration, and transitions are the same, they will play in unison.

Comment
Add comment · Show 3 · 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
avatar image T_Lavell · Feb 06, 2017 at 12:08 AM 0
Share

That assumes that I have first stored a reference to each animator - it wouldn't actually look like 'A.anim...', it would be more like

Animator _animA; Animator _animB;

void Start() {
_animA = characterA.GetComponent(); _animB = characterB.GetComponent(); }

public void BothPunch() { _animA.SetTrigger("Punch"); _animB.SetTrigger("Punch");

}

 Then call 'BothPunch()' etc
avatar image T_Lavell · Feb 06, 2017 at 12:09 AM 0
Share

Sorry for the crappy formatting, I'm on my phone.

avatar image Skar_Universe · Feb 06, 2017 at 03:44 AM 0
Share

Yea I tried that.. and your method works indeed most of the time but there are some animations that have exit times for one of my character which delays or sometimes skips the trigger. Removing exit times would make it look abrupt.

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

188 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

In my script the Animation selection pop up shows no assets even though i have several? 0 Answers

Alpha Layer Fade To Black Animation On an Inverted Sphere? 0 Answers

PROBLEM WITH ANIM.SETBOOL NOT WORKING 0 Answers

Rotating a joints transform while it's being controlled by Animator 1 Answer

Pausing and resuming animations Unity 5.2 0 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