Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
3
Question by Tharsman · Aug 21, 2011 at 03:47 AM · physicseditorscene

Physics in scene editor mode?

Is there a way to apply gravity and physics to objects within the scene editor without running the game? I have some scenes that can be a bit complex when they start, as object may be slightly out of place until gravity affects them and they go to sleep. This can be a bit taxing when loading levels in iOS, and although only lasts a few seconds, I would prefer if everything is ready to go to sleep from the start.

Alternatively: if i start the game from the editor, I can create a prefab of objects in the position I want, but using this prefab to replace components breaks the original prefab relationship. Is there another way to save these objects positioning without using this scene prefab approach?

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 twlomega · Aug 21, 2011 at 02:09 PM 0
Share

can't you just get the final testing position while in the editor, and then just make the objects start at the final resting position ins$$anonymous$$d of waiting for them to settle?

avatar image Tharsman · Aug 21, 2011 at 02:57 PM 0
Share

I have been trying that but it gets insanely time consu$$anonymous$$g in large levels with many inclined floors with, sometimes up to a hundreads bodies (reason those levels get so bad at startup)

4 Replies

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

Answer by Waz · Aug 22, 2011 at 12:20 AM

Yes, just drag the objects from the hierarchy to the project view during runtime. Or copy their transforms (with pen-and-paper or one of the tools you can get for that). You can then start the Rigidbodies Asleep.

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 Joshua · Aug 22, 2011 at 12:35 AM 2
Share

Or just hit ctrl+c in play-mode, ctrl+v in edit mode and delete the original.

avatar image Tharsman · Aug 22, 2011 at 12:40 AM 0
Share

THAT! THATS what I needed! Darnit, such a simple answer and me here struggling with that!!! I got to admit, I would never had guessed the Unity editor was capable of copying that kind of information in the clipboard.

Thank you!!! I guess I'll flag the answer you replied as the solution since you posted under it :)

Thanks!

avatar image
5

Answer by ThePilgrim · Oct 17, 2019 at 08:06 PM

You can simulate physics in the editor by setting Physics.autoSimulation to false, and using Physics.Simulate() to advance physics frame by frame until your objects are settled.

Here is an example editor window:

 using UnityEditor;
 using UnityEngine;
 
 public class ScenePhysicsTool : EditorWindow {
 
     private void OnGUI()
     {
         if (GUILayout.Button("Run Physics"))
         {
             StepPhysics();
         }
     }
 
     private void StepPhysics()
     {
         Physics.autoSimulation = false;
         Physics.Simulate(Time.fixedDeltaTime);
         Physics.autoSimulation = true;
     }
 
     [MenuItem("Tools/Scene Physics")]
     private static void OpenWindow()
     {
         GetWindow<ScenePhysicsTool>(false, "Physics", true);
     }
 }
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
avatar image
0

Answer by Anykey · Aug 21, 2011 at 05:16 PM

I don't really know what you want to do , but I would press Play icon and go back to the scene editor window to see the physic in the editor

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 Tharsman · Aug 21, 2011 at 05:31 PM 0
Share

Lets say you have 5 boxes. You place them in the map in the scene editor. Once you hit play, they fall to the ground, they may rotate as needed based on the floor angle and any other item that may be in the way.

What I want is to save that positioning so the game starts that way when the level starts up. Reason to do this is that in iOS, the initial process of accommodating these blocks can be very sluggish. In a case of only 5 items, its easy for me to manually edit the xyz position and rotation based off what happened when I hit play, but in much much larger scenes, this becomes extremely hard, tedious and error prone.

avatar image twlomega · Aug 21, 2011 at 05:38 PM 0
Share

honestly, i don't think you really have any other way to do it. off the top of my head there's only two ways that I can see you accomplishing this; 1) as you're building the scene in the first place, use play, get their final position and rotation, and set them as you make the objects, so you don't have to do a pass later to go through them all. 2) write 2 scripts.. one that uses an editor gui button that allows you to save a snapshot of all of the objects position + transform down to a file, ie: keyvalues (or i believe there's a dictionary class on the wiki somewhere, which is the same principle. and then a second script, that when the scene starts, it loads it's "initial position" from the dictionary, from it's unique name.

either way, it's going to be time consu$$anonymous$$g.

Oh, and that also means that in order to do it, you would have to make every object have a unique name, or some unique identifier, so that you can save the keys, and then load them properly.

avatar image Tharsman · Aug 21, 2011 at 06:15 PM 0
Share

Yea, the editor scripting sounds interesting and I'll look more into them for my next project.

But I think I'll go back to saving prefabs while within the editor, keeping a duplicate of the entire scene that has the original prefab associations. This was my "fallback" solution from the start but wanted to see if there was some built in feature I may had missed.

avatar image
0

Answer by Crazycarpet · May 19 at 06:48 PM

I see this is old but I use this asset: https://assetstore.unity.com/packages/tools/level-design/editor-physics-simulator-221538

Really simple and it lets you record animation clips of the physics simulations.

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

8 People are following this question.

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

Related Questions

Ho do I find all scenes with a certain script on an GameObject 2 Answers

Post-Process All Unity Scene GameObjects 1 Answer

Unity 4.6 Copying Complex GameObjects Between Scenes Resets Fields In the Editor 2 Answers

Cannot select multiple items in hierarchy / scene? 6 Answers

Accessing a UnityEditor class. 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