Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by growling_egg · Jun 13, 2014 at 06:39 PM · animationmecanimpathfindingastaranimationstate

Animation works, pathfinding works, but they don't work together.

I'm working on an RTS. I have a prefab basic unit I'm using as the framework for all my units. I'm using A* Pathfinding Pro, a very nifty pathfinding solution, and my unit can successfully navigate his way around my map, avoiding obstacles and the like.

My main issue comes from being able to work an Animator Controller - I've got it loaded with some animations like Idle, Walk, Run, etc, and when the game starts up the unit automatically enters the Idle state. However, I can't seem to a) loop animations appropriately (after Idle has played through it advances to my Run animation for a moment, then back to Idle), and b) the only way I've found to make the unit actually follow the path it generates in the pathfinder totally bypasses the animation, so he just remains in the Idle state while he floats towards the target position.

Here's my animator controller:alt text

Ultimately, I need my unit to remain in whatever state I put it in until I say otherwise, and I need to be able to use the movement animations to progress along the calculated path. If any other images or descriptions would help, I'm happy to oblige. Thanks for any help!

animator.jpg (55.2 kB)
Comment
Add comment · Show 2
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 christoph_r · Jun 13, 2014 at 07:12 PM 0
Share

Are you making sure you're updating the animator parameters (e.g. speed) based on what A* is doing?

avatar image growling_egg · Jun 13, 2014 at 07:22 PM 0
Share

I tried doing what they show in the script tutorial:

http://unity3d.com/learn/tutorials/modules/beginner/animation/animator-scripting

Whenever I attempt using the StringToHash function, I get a message saying Hash #(some int value) doesn't exist as a parameter. So basically, I haven't worked out how that process is supposed to be done. Is that how the animation and A* relate?

1 Reply

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

Answer by Bodkin · Jun 13, 2014 at 07:22 PM

For the transitions to other animations you have to set a parameter such as speed. Then use that to trigger your animation. For example the transition from idle to walk would be "Speed > 0" this can be set up when you press a transition arrow on the animator. The code ,however, would have to look like this:

  if (Input.GetKeyDown("space")){
 gameObject.GetComponent<Animator>().SetFloat("Speed",1);
 }
 else{
 gameObject.GetComponent<Animator>().SetFloat("Speed",0);
 }

Make sure to set the parameters.

For more information: http://www.youtube.com/watch?v=Xx21y9eJq1U

Comment
Add comment · Show 1 · 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 growling_egg · Jun 13, 2014 at 07:45 PM 0
Share

So helpful. Thanks a ton for that!

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

23 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

Related Questions

A* Pathfinding with mecanim and rotation 1 Answer

How to Change the Motion of an Animation State in an Animator Controller at Run-Time? 1 Answer

Animation state not transitioning at 100% 1 Answer

How to play character animation when using A* pathfinding 0 Answers

Why does this animator appear to occupy two states, but report only one? 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