Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Wolfrik_Creations · May 29, 2016 at 06:46 PM · javascriptgameobjectterrainfreezegameobject.active

Change the active value quickly?

Ok so I'm making my game have all different maps in one scene and I imagine that having like 10 HUUUGE terrains would affect my performance right?

Well I have this setup: alt text

and this function to load the maps, but changing the active state on this many objects is causing a 3 minute lag spike.

 var maps : Transform[];
 static var loadedMap : int;
 var terrain : Terrain;
 function LoadMap (index : int){
     loadedMap = index;
     sunGO.transform.position = maps[index].position;
     for(var i=0; i<maps.length; i++){
         if(i==index){
             sunGO.transform.position = maps[i].position;
             GameObject.Find("CloudDome").transform.position.x = maps[i].position.x;
             GameObject.Find("CloudDome").transform.position.z = maps[i].position.z;
             maps[i].gameObject.active = true;
             terrain = maps[i].Find("Terrain").GetComponent.<Terrain>();
         }else{
             maps[i].gameObject.active = false;
         }
     }
 }

Now I should give a little background on what this function does.

The "terrain" variable is simply what my walking sound script uses to check what terrain I'm on and then get the texture I'm on, nothing related to my question.

"CloudDome" is that thing you see in the distance on the main map.

"sunGO" is the GameObject that holds the sun, moon, weather, and other ambient things.

The "maps" variable is what holds the Tranform parents of the maps, see it here: alt text

Now if it froze just when loading a map, that would be fine, but it freezes as soon as I host a server because it's setting all of the other maps (only 2 maps at the time) to be inactive.

I apologize for this being so long, please help me fix this or at least come up with a workaround.

Thanks in advance!

capture.png (306.0 kB)
capture.png (4.6 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

· Add your reply
  • Sort: 
avatar image
0

Answer by DroidifyDevs · May 29, 2016 at 06:50 PM

I don't see why you have that many terrains in one scene. Why not just make separate scenes for each map? If you're loading many maps at a time of course you will have a lag spike. Regardless on whether or not your maps are active or inactive, at the start of the game it will still load all the objects, reducing performance and increasing load time. To make the load time shorter, you need to reduce the amount of stuff to load, so make the maps in separate scenes.

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 Wolfrik_Creations · May 29, 2016 at 06:55 PM 0
Share

It's complicated, the way everything is set up is for that scene, creating another scene (which I have done before in the game) causes a lot of problems for the game, also causes problems with players joining the server from a different map, which I could fix that but there are a lot of other problems with changing maps that I cannot deal with.

When the game starts, every map is active. When you join it hits a trigger in the map that your player was in to set all other maps inactive, this is when the game freezes.

Should setting them INactive really cause a lag spike?

Also thank you for the quick reply

avatar image Wolfrik_Creations · May 29, 2016 at 07:50 PM 0
Share

The lag isn't when I first start the game, that loads fine. It's when I actually click host it sets the other maps as inactive, that freezes it.

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

75 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

Related Questions

Car made from Different GameObjects and Empty GameObjects breaks on Collision with Terrain. 0 Answers

Fast way to texture a 10km map? 1 Answer

How to make a GUI bar that counts items collected 0 Answers

Copying or duplicating a gameObject from one scene to another 1 Answer

GameObject is passing through the mountains in the terrain. 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