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 sam32x · Jul 19, 2012 at 07:29 AM · physicsrigidbodytransformsomething

how do i make this lag less?

i have a script to make a breakable building and i attach it to every part so when a certain amount of force is applied it "breaks" i have the script attached to a small brick wall and the game goes at about 5fps, does anyone know how i can make it lag less?

 var startx : float = 0;
 var starty : float = 0;
 var startz : float = 0;
 var breakdistance : float = 0.5;
 var broken = 0;
 
 function Start () {
 rigidbody.freezeRotation = true;
 rigidbody.useGravity = false;
 startx = transform.x;
 starty = transform.y;
 startz = transform.z;
 Invoke("Loop",0.2);
 }
 
 function Update () {
 if(transform.x >= startx + breakdistance){
 Break();
 }
 if(transform.x <= -startx - breakdistance){
 Break();
 }
 if(transform.y >= starty + breakdistance){
 Break();
 }
 if(transform.y <= -starty - breakdistance){
 Break();
 }
 if(transform.z >= startz + breakdistance){
 Break();
 }
 if(transform.z <= -startz - breakdistance){
 Break();
 }
 }
 
 function Loop () {
 Invoke ("Loop",0.2);
 if(broken == 1){
 transform.x = startx;
 transform.y = starty;
 transform.z = startz;
 }
 }
 
 function Break () {
 broken = 1;
 rigidbody.useGravity = true;
 rigidbody.freezeRotation = false;
 }
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
-1
Best Answer

Answer by sam32x · Jul 19, 2012 at 07:38 AM

nvm i fixed it

Comment
Add comment · Show 3 · 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 CHPedersen · Jul 19, 2012 at 07:43 AM 1
Share

If you fixed it, could you please provide your solution? This is to keep the information on this board properly searchable. :P I.e., if someone googles for "Unity fix lag" in the future and it leads them to this post, the answer should be something else than "nvm i fixed it".

avatar image sam32x · Jul 23, 2012 at 09:17 AM 1
Share

i took everything in Update and put it in Loop

avatar image AwsomeRod · Dec 06, 2012 at 03:17 AM 0
Share

how, were is the update and loop?

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is there a solution to when colliders bypass? 2 Answers

Disable transform inheritance for rigidbody 1 Answer

Parenting not working with massive force to rigidbody. Does having rigidbody on child screw things up? 1 Answer

Rigidbody parent affecting rigid body of a child 2 Answers

My character moves under the terrain at strange Y position 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