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 BrinkHouseGames · Nov 27, 2013 at 07:58 AM · javascriptphysicsinstantiateframerateretina

Retina specific framerate drop on specific function

I'm working on a game that long story short involves a bunch of cubes flying around. Your player can destroy these cubes at certain intervals, causing them to "blow up", which is basically just instantiating an empty object containing 8 cube objects, (about 150tris each with mobile textures) they don't contain scripts only colliders and rigidbodies.

When running the game on a 1st gen iPad Mini the problem never happens and the framerate stays solid at 60fps. Only on the retina Mini will it bog down to 30fps if you blow up three or more cubes in close succession (0.5-1 second gap) and for the love of god I cannot figure out why. Here is the method that is called when the collision happens. Please let me know if I have something clearly wrong that could be causing such an issue on a current gen retina device.

Additionally, if you'd like more info/example I'd be happy to provide it. Thank you.

  function enemyClusterExplode()
  {
     audioMan.PlayCubeExplode(); //play sfx
     Destroy(this.gameObject);

     //instantiate at pos/rot of enemy cube
     var cubeCluster : Rigidbody = Instantiate(enemyCluster, transform.position, transform.rotation);
     cubeCluster.transform.localScale = gameObject.transform.localScale;

     //give the cluster an explosive force
     var explosionPos : Vector3 = transform.position;
     var colliders : Collider[] = Physics.OverlapSphere (explosionPos, explodeRadius);
     for (var hit : Collider in colliders)
     {
         if(!hit)
             continue;
         
         if(hit.rigidbody)
         hit.rigidbody.AddExplosionForce(explodePower, explosionPos, explodeRadius, 0.3);
     }
 }

UPDATE: I changed the instantiate call above to nested objects that simply get turned on/off when collision happens. Still getting the same issue when you hit 3+ cubes close together in time. I'll have to shift my attention elsewhere as this doesn't look like the problem.

At time of slowdown the stats are showing about 6.5k tris in the scene and between 20-35 draw calls happening. I'm still absolutely confused why this is only occurring on retina hardware…

 function enemyClusterExplode()
 {
     audioMan.PlayCubeExplode();
     cubeCluster.SetActive(true);
     cubeCluster.transform.parent = null;
     //give the cluster an explosive force
     var explosionPos : Vector3 = transform.position;
     var colliders : Collider[] = Physics.OverlapSphere (explosionPos, explodeRadius);
     for (var hit : Collider in colliders)
     {
         if(!hit)
             continue;
         
         if(hit.rigidbody)
         hit.rigidbody.AddExplosionForce(explodePower, explosionPos, explodeRadius, 0.3);
     }
     enemySpawnRef.maxRespawnTime -= 0.009f;
     enemySpawnRef.launchSpeed += 0.01f;
     this.gameObject.SetActive(false);
 }
Comment
Add comment · Show 2
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 deltamish · Nov 27, 2013 at 03:40 PM 0
Share

First of all you need to stop Destroying and instanting object at runtime

Ins$$anonymous$$d

for faster solution

Create a num object(lets say up to 10) during start and just enable and desable it at runtime

ins$$anonymous$$d of instantiating ti just set it position to the target position(transform.position in yuor case ) and enable the object and create a yield function to wait for few seconds the n disable the object

avatar image BrinkHouseGames · Nov 27, 2013 at 05:43 PM 0
Share

I agree that instantiating and destroying isn't the most efficient, but why would older, slower hardware NOT have a problem with this, while the newest hardware does?

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by BrinkHouseGames · Dec 07, 2013 at 08:46 PM

I figured out the problem. I had in quality settings the Anti-Aliasing set to 4x for a cleaner look on non-retina devices. I added a bit of code to check the resolution of the device and set the AA accordingly and that fixed the lag.

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

17 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

Related Questions

Overlapping instantiation issues. Help? 1 Answer

Instantiated child doesn't move along with the parent in case of low frame rates 0 Answers

Instantiate loading very slowly 3 Answers

How do I switch from Character player to Airship Vehicle using triggers? 0 Answers

Help with my On_Bullet please 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