• 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 Kazaskater · Jan 04, 2011 at 03:02 AM · gamegraphicsspeedquality

How can I speed up my game?

I am making a FPS, and the map isn't very big. Its about the same size as the unity demo. I have a main script that kinda takes care of stuff like the weapons, flashlight, scope, etc. Could the script possible be slowing down the game? It has like 20 variables and is about 700 lines of code. I have even tried disabling the script to see what would happen, but it didn't make much of a difference, so I don't think its the script. I have tried getting rid of as much trees and stuff as possible, but still, nothing. Any ideas?

Comment

People who like this

0 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

2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by d3coy · Jan 04, 2011 at 03:45 AM

Could be any number of things. Since the free version of Unity doesn't come with a profiler, it's hard to know. That's a big reason you should pay attention to your framerate after each and every change/addition you make to your game. Otherwise, you end up in a situation where you've no idea what the problem is.

Some big culprits are usually things like doing too many things every Update, too many physical objects, scene complexity... all obvious stuff. My advice to you would be to do what you've been doing -- removing possible performance degraders and assessing your performance after each removal.

Comment
SrBilyon

People who like this

1 Show 0 · 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

Answer by _Petroz · Jan 04, 2011 at 05:40 AM

This is based on the assumption that your application is CPU bound, there are many possible factors which can cause a game to run slowly.

The number of lines of code and number of variables is inconsequential. It is often a small section of code which slows things down. This is a good place to apply the '80:20' rule (80% of the time is spent executing 20% of the code). Without a profiler it's difficult to locate which areas of the code are slowest. The easiest method is to remove code and see what difference it makes to the performance.

The easiest way to prevent code from executing would be to rename 'Update' to something else such as 'Update_disabled'. Do this for one class, and run your game and measure the difference. Do that one by one for each class until you find that slow code. If you see a big performance boost after renaming one function, then you have found the problem. Next you can use block comments or preprocessor directives to remove chunks of that function and narrow down the search further.

Once you find the code, optimize it. Generally algorithmic optimizations are better, although code tuning can prove useful in tight loops.

Comment
SrBilyon

People who like this

1 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 Kazaskater · Jan 04, 2011 at 10:01 PM 0
Share

Thanks for the response. I just removed the entire script to see what would happen, and still, nothing. It still goes pretty slow. I have a pretty fast computer too. I have a mac with a dual core 2.53 ghz processor, and 4 gigs of ram, so it shouldnt be that slow.

avatar image _Petroz · Jan 04, 2011 at 11:07 PM 0
Share

It's probably not the code that is the problem them. How many polygons do your meshes have and how many meshes are there?

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

No one has followed this question yet.

Related Questions

Pixelartifacts on edges when activating Antialiasing... 4 Answers

Unity game portals that don't monitor game quality? 0 Answers

PNG / SVG (Vector Graphics) sprites quality 1 Answer

load scene Assetbundle and the lightmap crash 0 Answers

Android Build has bad quality 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