• 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
Question by Digital-Phantom · Jan 17, 2015 at 07:47 AM · animationjavascriptperformancegpuspin

Script or Animation,which is best for performance?

I have an object in my game that I want to spin constantly. At times (not always) there may be several of these in one scene. I have a very simple script that does the job at the moment-

 #pragma strict
 
 var spinx : int = 0;
 var spiny : int = 3;
 var spinz : int = 0;
 
 function Update () 
 {
     transform.Rotate(spinx,spiny,spinz);
 }

OR... would I be better off using an animation? W$$anonymous$$ch is going to be the more efficient option?

Comment
Denvery
Glurth
skjagan

People who like this

3 Show 0
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
Best Answer

Answer by Haseeb_BSAA · Jan 17, 2015 at 06:27 PM

The best option will be the one that suits your game. If rotating by script is just as fine as an animation then script will be a better option since you don't have to worry about keyframe problems and the movement will be steady! But if that doesn't look good with script , go for animation.

Function Update will keep rotating the object in all 60 frames of your game. If you write animation.Play("Name"); In the Function Update , it really wouldn't make any difference since it will play the animation in 60 frames as well. The choice is yours :)

Comment
Digital-Phantom
FlightOfOne
Chuckler
Hoorza
unity_94d33m

People who like this

3 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 Glurth · Mar 06, 2015 at 05:06 PM 2
Share

This does not really answer the root question: which is more efficient? (then again, I'm interpreting "efficient", as faster, rather than easier to code.)

avatar image jimmy12day · Jan 09, 2019 at 07:20 PM 0
Share

if you use Time.Framerate%=N, then it will be every N frame it play the animation. It won't help if you have to do fast rotation cause you have to rotate this much frame.But still, scripting allow you adjust parameters easer. More control means you have choice. Animation is simpler way but not flexible.

avatar image skjagan jimmy12day · Aug 16, 2020 at 05:56 AM 0
Share

Its not about the extent we can utilize it, its about which will have less load on the system i.e. "efficient" while playing.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

28 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

Related Questions

Adding animation clips via script 2 Answers

Animation play when dead 2 Answers

How do I destroy a game object when it is hit by a weapon? 3 Answers

sliding door animations 1 Answer

how to take maya animation file in to unity? 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