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 Hexer · Jul 21, 2013 at 08:32 PM · javascriptgravitylagslow

Adding gravity to my gameobject causes lagg

I got a problem. When i add gravity to my prefab and click on play, everything gets slowed down.

The gameobjects won't fall in a normal way. ( it seems like they got some kind of delay, they drop down for a second and stops for a second, this repeat itself over and over again. )

The strange part is that this problem will only appear when my map of blocks is 30x30x1 (x,z,y) or higher.

 var block : GameObject;
 
 //Change to adjust the lenght = x and z
 var worldWidth : uint  = 30; 
 var worldHeight : uint  = 30;
 
 function Start () {
  
 CreateWorld();
   
 }
   
 function Update () {
 }
  
 function CreateWorld() {
    
     //Space between each block (x)
         for(var x : uint =0; x<worldWidth; x+=1) {
        
        
      //Space between each block (z)
          for(var z : uint =0; z<worldHeight; z+=1) {
          
  
          
           var block = Instantiate(block);
           block.transform.position = new Vector3(this.transform.position.x + x, this.transform.position.y, this.transform.position.z + z);
    
          
          
           }       
           }    
           }

This is the script i use, its Javascript.

Can someone please explain why it laggs so badly. Is it my script? has it to be in C#? I want to use it to make a floor out of cubes, those cubes will fall down when triggered by the player.

I hope you can help me

  • Kind regards, Hexer

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
Best Answer

Answer by IgorAherne · Jul 21, 2013 at 09:41 PM

1) check that the sizes of cubes are close to real ones, for example, car is 2 meters in length, etc.

2) Go to Project Settings - Time and check that Fixed time step is smaller or equal to 0.02

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 Hexer · Jul 22, 2013 at 07:59 AM 0
Share

1) I tried to change the scale of the cubes and then i adjust the variable in the script. When i click on start my Unity crashes.

2) Adjusting the Fixed timestep doesn't work. It's on 0.02 but when i try to change it to 0.01 everything get even worse.

I have found that adjusting the timescale(1) to timescale(0,5) helps abit. but it makes the moment of my character slow.

avatar image Hexer · Jul 22, 2013 at 08:44 AM 0
Share

Never$$anonymous$$d, thanks for your answer. it helped me out. It is still not that smooth but i think i can change that.

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

16 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

Related Questions

This is making heaps of lag 1 Answer

Character teleports to the apex of full jump height 0 Answers

Rigidbody y velocity is stuck on 0, gravity is not turned off. 2 Answers

Why does my game lag horribly after 4 A.I. spawn? 0 Answers

puzzle with rotating statues 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