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 /
This question was closed Oct 01, 2020 at 01:11 AM by Odinwastaken for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Odinwastaken · Sep 29, 2020 at 01:50 PM · physics2dlagperformance optimizationcpu usage

How To Reduce Physics Lag?

So at the moment when I run my game I get around 110% cpu power after around 30 seconds of my game being ran. Im very new to this and this is a barely made 2D game.... So I know I'm doing something VERY wrong. The game slowly increases in physics use. It was good until I started to try to add A* pathfinding to two of the enemies. I have two trigger colliders in the game as a whole. All my rigibody's are dynamic and one of the the enemies with A* has a rigibody and collider to try to give them gravity which isn't working atm. Any one got any tips and tricks to keep my game not running like a burnt potato. Thanks alt text

capture.jpg (53.1 kB)
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

  • Sort: 
avatar image
0
Best Answer

Answer by rh_galaxy · Sep 29, 2020 at 03:22 PM

I would guess that you somewhere in the code keep creating objects that you forget about... If you look at the memory usage you can confirm it, also you can try this and look at the console to see if the number of objects increases with time for no reason.

Add this line to Update in a central object that you only have one of.

 Debug.Log("Num obj is " + UnityEngine.Object.FindObjectsOfType<GameObject>().Length);
Comment
Add comment · Show 4 · 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 Odinwastaken · Sep 29, 2020 at 11:15 PM 0
Share

I used the line of code that you sent in the player object and it never went up and stayed at 35 for the whole time. I ran another test and here are the results for the physics. (For when the sleeping body become a active body is when a trigger is trigged to activate a enemy though not sure why it does it more than once because only 1 enemy has that) @rh_galaxy

alt text

capture1.jpg (55.8 kB)
avatar image rh_galaxy Odinwastaken · Sep 29, 2020 at 11:55 PM 0
Share

Well then my guess was wrong... That was the first thing I could think of causing an increase in physics load. You will have to dig deeper in the profiler data and see if you can find what it is... It should be possible to see in more detail what is causing the CPU-load...

avatar image Odinwastaken rh_galaxy · Sep 30, 2020 at 03:23 AM 0
Share

Ok so I did a little more digging and found that it was the enemy with A* causing all the lag. I'm not sure quite why though. $$anonymous$$ight be something to do with the path finding of it because when the player dies it stops the lag. Could also be the rigidbody. How would you suggest to fix A* or are there any good videos to watch about the subject? @rh_galaxy alt text

capture.jpg (27.3 kB)
Show more comments

Follow this Question

Answers Answers and Comments

143 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 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 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 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 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 avatar image avatar image avatar image

Related Questions

Problem with profiler spikes caused by Semaphore.WaitForSignal 0 Answers

Reduce Physics2D Lag 0 Answers

Just One of my scene is so laggy 0 Answers

Big Jerk or Lag when starting the game in Iphone caused by Shader.CreateGPUProgram, BatchRenderer.Flush and MeshSkinning.Render 0 Answers

Snapping System Optimized 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