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
1
Question by kburkhart84 · Apr 24, 2012 at 08:09 PM · physicsstartupinitialization

Physics not initializing right away upon Play Testing in the editor

I'm designing a simple asteroids clone with Unity, in order to get to grips with it before I tackle bigger projects. I've created a ship object, that uses physics for the movement. I've been able to get the movement right, so I know in general the physics system is working fine. But, for some reason, when I click the play button to test things out, the physics doesn't work for about 9 seconds. After that, it works fine, and I'm able to tweak public variables in my scripts.

The rest of the game seems to be working fine, making the ship shoot, and it doesn't wait at all, since it doesn't use a rigidbody, rather a sphere collider set as a trigger. Honestly, I don't remember having this problem when I was testing the version right before the newest version. I'm using 3.5.1f2 at the moment, and before I was using 3.5.??, and I don't remember the exact one. Here's the code for the ship object. You can see it is actually pretty simple.

 var turningDrag:float = 1;
 var normalTurningDrag:float = 1;
 var warpingDistancex:int = 42;
 var warpingDistancez:int = 32;
 var playerBullet:GameObject;
 
 private var canShoot:boolean = true;
 
 
 function Start ()
 {
 
 }
 
 function FixedUpdate ()
 {
     //Turning
     var turning = Input.GetAxis("Turn");
     if(turning > 0.70)
     {
         rigidbody.angularDrag = turningDrag;
         rigidbody.AddTorque(0, turningForce, 0);
     }
     else if(turning < -0.70)
     {
         rigidbody.angularDrag = turningDrag;
         rigidbody.AddTorque(0, -1*turningForce, 0);
     }
     else
     {
         rigidbody.angularDrag = normalTurningDrag;
     }
     
     //Thrusting and Strafing
     var thrusting = Input.GetAxis("Thrust");
     var strafing = Input.GetAxis("Strafe");
     if(thrusting!=0 || strafing!=0)
     {
         rigidbody.drag = thrustingDrag;        
     }
     else
     {
         rigidbody.drag = normalDrag;
     }
     if(thrusting != 0)
     {
         rigidbody.AddRelativeForce(0, -1*thrusting*thrustingForce, 0);
     }
     if(strafing != 0)
     {
         rigidbody.AddRelativeForce(strafing*thrustingForce, 0, 0);
     }
     //Warping to other side
     if(transform.position.x < -1*warpingDistancex)
         transform.position.x = warpingDistancex;
     if(transform.position.x > warpingDistancex)
         transform.position.x = -1*warpingDistancex;
     if(transform.position.z < -1*warpingDistancez)
         transform.position.z = warpingDistancez;
     if(transform.position.z > warpingDistancez)
         transform.position.z = -1*warpingDistancez;
         
     //Shooting
     if(Input.GetAxis("Shoot"))
     {
         if(canShoot)
         {
             var bullet = Instantiate(playerBullet, transform.position, transform.rotation);
             canShoot = false;
         }
     }
     else
     {
         canShoot = true;
     }
 }

Remember, the shooting part works right away, but for some reason, the ships receiving the forces does not. At one point, I put a quick log output in one of the if statements there and it does output right away. Also, the physics doesn't "add up" whatever is being done, rather it seems to ignore completely any forces until the about 9 seconds is up.

Any ideas?? Is there a setting I missed? I'm clueless at this point.

Thanks in advance!!!

Comment
Add comment · Show 1
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 kburkhart84 · Apr 25, 2012 at 05:48 AM 0
Share

I just tested this through the build and run as well, and also ran it from outside of the editor, after the build. In both cases, and in the editor, it is about 9 seconds before the physics responds. But it isn't an input issue, because the shooting input works fine, right from the start.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by kburkhart84 · May 04, 2012 at 02:40 AM

I finally stumbled upon a post in the Blender/External Tools Section of the forum here.

Basically, the model was doing the "default-take" animation from Blender, and the solution was to force it to not import animations, since my ship is a static model anyway. Suddenly, it responds instantly to physics like it should.

Comment
Add comment · Show 1 · 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 Bunny83 · May 04, 2012 at 03:17 AM 0
Share

:D Those "unwanted-animations-override-my-movement" problems are quite common ;) Good you figured it out ;)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Does Unity support application bootstrapping? 1 Answer

How to manage expensive startup/initialization operations without Unity hanging? 3 Answers

Android: slow at start, then speeds up. Can the initialization be forced? 0 Answers

startup initialization error with unity 3 0 Answers

Initialising List array for use in a custom Editor 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