Objects Disappear After Unity Simulation
I want to make changes directly to a scene loaded in Unity, but the objects disappear when the simulation ends. Is there a solution for this?
If I want to add movement or interaction to loaded scenes, how should I do it?
The ProcThor/Holodeck scenes only appear at running time. I'm not sure if it is possible to edit them in Unity. @AlvaroHG, do you have any comments?
Hi I'm interested too in this Topic. I'd like to move some objects around using the Unity interface, maybe take some pictures and then save the state of the world. Do you know if this is possible? How can we do it?
@basteran Hi! I've managed to move objects to match an expected layout by adjusting the generated .json file. It can be a bit time-consuming, so if anyone has a more efficient method or tool for this process, please let us know!
Here's how you can do it:
- Locate Object Data in the JSON File: Find the rotation and position of each piece of furniture under the "objects" section in the JSON file. It should look something like this:
"objects": [
{
"assetId": "Bed_9",
"id": "bed-0 (bedroom)",
"kinematic": true,
"position": {
"x": 1.2107633399963378,
"y": 0.6772908568382263,
"z": 1.5
},
"rotation": {
"x": 0,
"y": 90,
"z": 0
},
"material": null,
"roomId": "bedroom",
"vertices": [
[246.65266799926758, 41.439504623413086],
[246.65266799926758, 258.5604953765869],
[-4.5, 258.5604953765869],
[-4.5, 41.439504623413086]
],
"object_name": "bed-0",
"layer": "Procedural0"
}
]
- Adjust Object Position and Rotation in Unity: After connecting to Unity, move the objects to the desired positions and rotations within the scene. For example, let's say you move the bed to:
"position": {
"x": -1.2,
"y": 0.6772908568382263,
"z": 0.5
},
"rotation": {
"x": 0,
"y": 45,
"z": 0
}
- Update the JSON File: Go back to your JSON file and update the position and rotation fields with the new values. Save the changes.
- Reload the JSON File in Unity: Reconnect to Unity with the updated JSON file. Check if the objects have been correctly moved to the new positions.
@basteran Hi! I've managed to move objects to match an expected layout by adjusting the generated
.jsonfile. It can be a bit time-consuming, so if anyone has a more efficient method or tool for this process, please let us know!Here's how you can do it:
- Locate Object Data in the JSON File: Find the rotation and position of each piece of furniture under the "objects" section in the JSON file. It should look something like this:
"objects": [ { "assetId": "Bed_9", "id": "bed-0 (bedroom)", "kinematic": true, "position": { "x": 1.2107633399963378, "y": 0.6772908568382263, "z": 1.5 }, "rotation": { "x": 0, "y": 90, "z": 0 }, "material": null, "roomId": "bedroom", "vertices": [ [246.65266799926758, 41.439504623413086], [246.65266799926758, 258.5604953765869], [-4.5, 258.5604953765869], [-4.5, 41.439504623413086] ], "object_name": "bed-0", "layer": "Procedural0" } ]
- Adjust Object Position and Rotation in Unity: After connecting to Unity, move the objects to the desired positions and rotations within the scene. For example, let's say you move the bed to:
"position": { "x": -1.2, "y": 0.6772908568382263, "z": 0.5 }, "rotation": { "x": 0, "y": 45, "z": 0 }
- Update the JSON File: Go back to your JSON file and update the position and rotation fields with the new values. Save the changes.
- Reload the JSON File in Unity: Reconnect to Unity with the updated JSON file. Check if the objects have been correctly moved to the new positions.
Hi @zoeyliu1999 , thanks for your suggestions!
I have some issues with what you said:
- I cannot connect to Unity: I tried to use a Virtual Machine with Ubuntu 24.04 and Unity won't even start. I downloaded Unity on my Windows computer, Unity starts but it fails to load the Scene from file (using the specified script from the guide) as the Unity script has many errors.
- How can I get the new position and rotation of an object while Unity is still open in order to update the JSON file?
- What if I want to add or remove an object to/from the scene?
Thank you, I hope you can give me more support. I think it could be interesting to provide this kind of action to a developer for tuning the scene generated with Holodeck. It's a great tool, but in my opinion, it is too heavily dependent on ChatGPT and its generation..
Hi @basteran, regarding your issues:
-
You might consider asking the authors for advice. I'm using macOS, and
connect_to_unity.pyworks for me. -
After running the script to connect to Unity, you should be able to see the exact scene and move objects within Unity. Once you've adjusted the objects to your desired position, you can check the new position and rotation in Unity, as shown in this image.
-
Yes, you can remove objects from the scene by deleting their descriptions in the JSON file. However, I am still figuring out how to add objects to the scene.
Hope this helps!
Thanks @zoeyliu1999 , I still have some questions:
- Ok, I'll consider opening a new Issue about it
- What do I do with the new position and rotation? Should I manually create/update a "bed" object (as in your example) in the JSON and add the position and rotation from the Transform Tab from Unity?
- What if I remove a "receptacle" object, such as a table, that holds some other objects on top of it? That becomes tricky..
Thanks again, I really appreciate your help!
I implemented a feature that allows saving and loading of objects even in play mode.
https://drive.google.com/file/d/16e79pdidW5lvNdB5c9tWOMrChry0YJ4N/view?usp=sharing.
But every time I load, the objects keep sinking. LOL
I implemented a feature that allows saving and loading of objects even in play mode.
https://drive.google.com/file/d/16e79pdidW5lvNdB5c9tWOMrChry0YJ4N/view?usp=sharing.
But every time I load, the objects keep sinking. LOL
I guess you're making some mistakes when computing the y value for every object, even those hung on a wall!
I implemented a feature that allows saving and loading of objects even in play mode.
https://drive.google.com/file/d/16e79pdidW5lvNdB5c9tWOMrChry0YJ4N/view?usp=sharing.
But every time I load, the objects keep sinking. LOL
It looks like you were setting each object's y value to 0. For floor objects, you need to add half the object's height as the offset for the y-axis.
@TREEANA How did you do this? Can you share the code?