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 Carthage · Sep 09, 2013 at 03:28 PM · function updatekey-frame animation1 frame

How advance animation 1 frame at a time?

I want to advance animation at a strict rate of exactly 1 frame per update. I do not want any skipped frames which I believe unity will do if you just set it to play an animation.

So it would look something like

function Update() { gameObject.animation.advanceOneFrame(); }

I want to do this so that attacks have the same consistent frame data.

A punch should have 4 frames of startup and 10 frames of recovery for example, allowing for the player to always have the same things work.

Kick X will always be able to hit after blocking Punch Y, but I think this will not happen properly if frames are skipped.

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 Whisper_Leaf · Jul 13, 2016 at 01:16 AM

Sounds like you're making a fighting game? Well, here's the good news: Update() will strictly run once per frame, though not necessarily at the exact same timing each frame. On the other hand, the animator will always run based on Time.deltaTime, but should be separate from your actual game logic. If you're getting skipped animation frames, then that's a symptom of not running at 60 fps, rather than a problem in and of itself.

What this means is if you're counting in frames (rather than Time.deltaTime), you can be certain that the frame data of your game will be consistent, though not necessarily the timing of each action. The downside to counting in frames (instead of Time.deltaTime) is that any drop in frame rate will result in attacks dragging on for longer than they should, and if you're balancing around reaction windows, this can subtly shift expected timings. If you're going to count in frames, you absolutely must be certain that you are running at a smooth 60 fps (or whatever your target is). If you can do that, then the problem solves itself.

If you insist on having the animation sync up with the reduced frame rate rather than fixing the frame rate problem itself, it's possible to set the playback time each frame. If you call animator.SetTime(currentDesiredFrameInAnimation / maxFramesInAnimation); every frame, it will ensure that the playback time of the animation matches whatever frame rate you're running at. Animator.SetTime() is how I implement hitstop and Super freeze in my own fighting game, so if you're planning on implementing those or similar features, you'll probably need to use it anyway.

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

16 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

Related Questions

Performance of Line Renderer Functions 0 Answers

my object instantiates to much 1 Answer

Can I create a script that makes an animation advance 1 frame for each keystroke? 4 Answers

BCE0023 Error 1 Answer

How to track an object per Frame? 1 Answer


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