Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
1
Question by Caps · Feb 01, 2011 at 02:45 PM · animationproceduralpauseframe

Playing animation frame by frame by procedural controller

Hi guys,

I have read the post regarding "Freezing an animation on a certain frame" as a reference for something Ill be trying to do...

Im wondering if it is possible to play an animation frame by frame by a procedural control?

The idea would be to use this for the characters aim.

I have the character animated in a 3D package (Maya/Max/Whatever) wich would be aiming straight downwards, straight ahead and aiming upwards.

Is it possible to have the animation set and paused at a certain frame depending on the characters aim angle? So if it aims at max limit upwards the animation would be set and paused at the last frame of the sequence, wich would be aiming up, as character points aim downwards, the actual animation frame played and displayed would be that corresponding one till he reaches the straight aim, then aiming downwards and so forth.

Has anyone tried anything similar? Would be this the best way or would anyone happen to know a better way to make character aim procedurally?

Im sure this would be something quite common to be implemented in games...

Oh, and I forgot to mention that this would be set at LateUpdate()...

If someoneo could help out! :D

Thx in advance! :D

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

5 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Toxic Blob · Feb 01, 2011 at 04:22 PM

This is very much possible. By directly controlling the time of the animation you could have, say, time=0 be aiming down, time=1 aiming straight ahead and time=2 straight up. Then by using AnimationState you can manually set the time, and thus the animation to display.

Comment
Add comment · Show 2 · 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 runevision ♦♦ · Feb 01, 2011 at 04:35 PM 0
Share

This method is actually also used for ai$$anonymous$$g in the Bootcamp demo that comes with Unity 3.

avatar image Caps · Feb 01, 2011 at 05:35 PM 0
Share

Thats cool guys, thanks a lot for your responses, I guess with this support Ill go ahead and give it a try! :D

avatar image
2

Answer by Caps · Feb 06, 2011 at 06:18 PM

Ok guys,

It works!

Just to clarify some things to others that might try this approach:

As mentioned, I used a character animated aiming up and aiming down, the straight aim is the default pose wich would be frame 0. So the animations go (as an example) from 0 - aiming straight ahead, 90 - aiming 90 degrees up, 100 aiming straight ahead again to 190 aiming 90 degrees downwards.

Use your mouselook script to get the direction player is aiming in the x axis. in my case, Im using full 90 degrees for aiming upwards and -90 degrees for aiming downwards.

(I noticed most games dont go that far, like Counter-Strike, Battlefield etc., if you watch the character even if he aims straight up the character pose in game has a limit of about 60-70 degrees)

So in unity, have your animations for aiming up and down split or seperate, set their blendmode to additive and finally set the animation time (wich would be our desired frame/pose for the corresponding angle of aiming) in seconds, since our framerate is set to 30 FPS for animation in the 3D package (maya/max/whatever), for 0 to 90 frames of animation we have 0 to 3 seconds, wich is what unity uses.

something simple like: animation["AimUp"].time = camera.aim_x /30;

So this is the way I got it working! :D

Thanks again guys!

Cheers!:D

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 Deminetix · Jan 25, 2014 at 10:39 AM 0
Share

This works exactly as intended

avatar image
0

Answer by Framklin 1 · Apr 28, 2011 at 01:39 AM

Hey man!

I'm trying to use your approach for my 3rd person shooter game. I'm running into some complications though. My character is shaking up and down while aiming with his hands. Did this happen for you? Could it be that i'm in between two different frames? Thanks in advance!

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 Thomassucks · Jun 18, 2011 at 07:17 PM

Hey, in "animation["AimUp"].time = camera.aim_x /30;" is "camera.aim_x" in your mouse look script? im relatively new to scripting, can you explain the way you do this just a little more? thanks

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 Noob_Vulcan · Sep 18, 2015 at 06:46 AM

Well if you want to do that in Animator then use this

Lets say you want to play the animation from the mid frame .This is how u will do it

 getComponent().Play(“Animation_Name”,0,0.5f);

or

 getComponent().Play(“Animation_Name”, 0 , (1/total_frames)*frame_number);

For more you can refer here http://www.unityrealm.com/play-animation-from-frame-unity-5-animator/

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to stop sprite animation on single frame? 0 Answers

Playing animation frame by frame depending on speed (time) 1 Answer

Blend tree like effect on one animation ? 0 Answers

Play an animation from the animator at a specific FRAME using anim.Play(); 3 Answers

Mecanim How get the last frame the animation? 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