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 Glacier Games · Jun 06, 2013 at 04:38 AM · rigidbodyanimatormecanimavatar

Mecanim deltaPosition is increased with more avatars

Hey guys, so I successfully figured out how to (for the most part) take the mecanim deltaPosition and use it to change a rigidbody's velocity. It was pretty simple really; Instead of saying:

 transform.position += anim.deltaPosition;

I implemented rigidbody velocity to get a more realistic movement:

 rigidbody.velocity.x = anim.deltaPosition.x*60;
 rigidbody.velocity.z = anim.deltaPosition.z*60;
 rigidbody.rotation *= anim.deltaRotation;

Now, it was working perfectly until I added another character into the scene with a different avatar, but same controller. I ran the game, and through some debugging, I found out that the characters were actually moving twice as fast as before. More importantly, I found out that their deltaPositions were doubled. Puzzled, I removed one of the characters, and then it worked perfectly again. How was the deltaPosition increased with the addition of another character? Is there anyway around this?

Update: Does not only occur with more avatars. Occurs whenever frame rate goes down.

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
Best Answer

Answer by BenDriehuis · Jul 03, 2013 at 01:43 AM

Hi there,

The reason you are seeing an increased delta position when the frame rate decreases, is because the delta is showing you how far the anim has moved this frame.

Because the frame took longer, more of the animation took place.

The reason you are seeing the characters moving faster is because you are multiplying the delta position by a constant value.

This might work "perfect" for the frame speed you were on with one character, but when you have a slower frame speed, your velocity will be being set to a much bigger value. You want to know how far they are moving per consistent time unit, not how far they are moving a frame, to set the velocity.

What you want to do is something like the mecanim examples on the asset store. Their nav mesh example sets the velocity like this:

 agent.velocity = animator.deltaPosition / Time.deltaTime;

You should be able to do the same and see similar results. You can then apply your speed modifier to the result of animator.deltaPosition / Time.deltaTime get them to be faster/slower afterwards.

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

15 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

Related Questions

Is it currently possible to do a complete Mecanim setup via script? 1 Answer

How does the Animator drive Rigidbody with root motion (in detail)? 1 Answer

Animator overriding collisions? 0 Answers

Mecanim - pause animation layer 1 Answer

No Avatar for Legacy rigs... Mecanim fails? 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