Monkey Frog Studio Posted January 3 Posted January 3 I'm finding that prefabs aren't working quite as expected. I made a simple test. Numbers correspond to images attached. 1 - I created a simple map that contained one brush for the floor and the stock barrel object. The barrel is the child of the box brush. I then saved the map as a prefab. 2 - I started a new map and dragged in the prefab. Then I dragged in two more copies from the right-side panel for a total of three. Then I saved the map. 3 - I opened the original prefab file and moved the stock barrel model to a new position and saved it. 4 - I opened the previous map with the three instances of the prefab and the stock barrel model was not repositioned but maintained the original barrel position. To be sure, I exited the Leadwerks editor, restarted and re-loaded the same map. The barrel did not move. 5 - I opened the prefab file again and added a new barrel (one of my own custom models) and saved the prefab. Then I opened the map file with the three instances of the prefab. The first prefab I had originally placed showed the newly added barrel model. The original stock barrel model was still in its original position (i.e. it had not moved even though I had moved the barrel in the prefab). My expectation is that if I alter the original prefab that any map that references that prefab will update to those alterations when the map is opened in the Leadwerks editor. So far, this is not happening. 1 Quote Creating professional 2D and 3D content is my passion! Monkey Frog Studio
mdgunn Posted January 3 Posted January 3 Did a little test. I agree prefabs do no update as expected. My case may be different (or the same, I don't know) as I am experiencing headaches with brushes and prefabs. About 100% of the time brush based prefabs do not update as I expect and I have to delete ALL old instances and put new copies in and they will look as I hoped the update would have made them look (but did not). Here is an image of what is about to be explained. Try the following 1) Create a box, anywhere EXCEPT the centre of the world. World centre would be stupidly convenient of course so we don't do that. 2) Save as prefab. Prefab will inherit the old world position which to me feels like it probably never what you want. 3) On the original map place the prefab some where else not at world centre. If it's a brush it won's sit on surface as you might hope but rather use the root object centre. To avoid this if I use a pivot to provide an origin point for the brushes that I make children of the pivot. I don't want to commit to moving to a 3D program yet brushes are just fine at this stage! The pivot then interferes with the ability to edit the brushes (have to move brushes out, edit, put back under pivot etc. super painful and prone to error). Anyways....next. 4) Enter prefab and add a box or other geometry to it. Will look fine in prefab. 5) In world the box will appear based on the location of the original item. If you didn't delete the prefab source the original prefab source will gain the new geometry and the ACTUAL prefab will appear to not gain the geometry because it's getting offset back to the position of the original. This feels like a SUPER weird and confusing situation to me. In the image you can see the red box and yellow box appearing over the original green box when in the prefab they were put over the green box. Odd because it LOOKS like the original got updated (which isn't itself even a prefab at this point) and the prefab appears not to be update but it did but the objects are updated back to the original world offset and not by their relationship to the geometry inside the prefab. 1 Quote
Monkey Frog Studio Posted January 4 Author Posted January 4 I did further testing with prefabs, this time without using any brushes, but just models. I still ran into issues. This time, I brought in a barrel model and placed a single book on top of the barrel and saved it as a prefab. I started a new map and populated it with three of the barrel/book prefabs and saved. Then I opened the prefab and added a second, different book model and saved the prefab. When I opened the map file with the three instances of the prefab, only the first (initially placed) prefab was visible, but the second book had been properly added. The other two prefabs actually were there (you could see them in the scene editor), they just weren't visible in the Leadwerks' editor. However, selecting them in the scene editor and then moving them made them suddenly appear (see attached images). Quote Creating professional 2D and 3D content is my passion! Monkey Frog Studio
Monkey Frog Studio Posted January 4 Author Posted January 4 Did another test with the barrel and books. I moved the books (moved and rotated) and saved the prefab. Then I opened the test map that uses three instances of the prefab. Like in my previous post, the first barrel and books was visible while the second and third were invisible in the editor (see post above). Selecting and moving them made them visible again. However, the books were moved and rotated ONLY on the initially placed prefab (the one that's visible when the test map is opened). The other two prefab instances retained the original book orientation and position (see image). Quote Creating professional 2D and 3D content is my passion! Monkey Frog Studio
Josh Posted Monday at 12:54 AM Posted Monday at 12:54 AM I am not ignoring this, I just know it's probably going to take a lot of intense focus for a few hours and I want to be prepared so I can solve it in one sitting hopefully... 2 1 Quote Let's build cool stuff and have fun.
Josh Posted 8 hours ago Posted 8 hours ago Okay, so currently the scene stores a unique position/rotation/scale for every objects, including sub-objects of prefabs. Changing the object's position in the prefab will not change its position in the scene, because it already has one that is established. This is by design, because otherwise there would be no way to reposition sub-objects of a prefab, they would just always be frozen in place, relative to the parent. Quote Let's build cool stuff and have fun.
Monkey Frog Studio Posted 6 hours ago Author Posted 6 hours ago Thanks, Josh. However, I don't believe this is the best solution. The way to reposition sub-objects in a prefab, independently of the others, is to disassociate it from the main prefabs. Thus, there should be a method of taking a prefab instance in a scene, perhaps right-clicking on it, and selecting something that causes the selected prefab to just become standard level stuff (geometry, lights, etc.). The current design restricts how prefabs can be used. For example, in Unreal, we can create a prefab as part of our grayboxing to establish the flow of a level. Then, once we have the level the way we like, the main prefabs can be finalized (final models added, stuff moved about, etc.) to create the final look of the game. Here's a tutorial video on how it's typically done and why: I hope this is helpful. Quote Creating professional 2D and 3D content is my passion! Monkey Frog Studio
Josh Posted 6 hours ago Posted 6 hours ago You have the ability already to convert a prefab into a non-prefab entity: The bigger question is, should the entity transform (position, rotation, and scale) of prefab sub-objects be stored in the prefab file, relative to the root, or should it be stored in the scene file? If I change this behavior, there will be people arguing that I should have done it the other way. So we need to discuss whether one or the other approach is better. Quote Let's build cool stuff and have fun.
Monkey Frog Studio Posted 6 hours ago Author Posted 6 hours ago Good question. Did you watch the video I linked to so you can see how powerful a tool a prefab can be when you can alter the main prefab and all instances follow? It just makes sense (to me) that I can alter one (the original prefab) and have those changes propagate over all instances, be those changes scale, rotation, or position. And the 'prefab' I'd not want to be affected (or if I only want one or a few affected) would be disassociated from the main prefab so it could be unique. Image I create a prefab to populate a hall in a sci-fi spaceship. I use 20 or 30 of these pieces to quickly set up the halls. Then I decide I need to make a change (for whatever reason - game flow, aesthetics, whatever). It would be nice to simply be able to load the single, original prefab and make those changes there, save it, and have all instances in every level update to reflect those changes. Quote Creating professional 2D and 3D content is my passion! Monkey Frog Studio
Josh Posted 6 hours ago Posted 6 hours ago I can't watch a 15 minute video. I think I got the point of what you are saying, you want changes to subobject orientations to be reflected in the scene. I kind of agree, but before I make such a change I need to inquire with the community and my own artists, to ensure they don't have an argument why the opposite should be true. Quote Let's build cool stuff and have fun.
Monkey Frog Studio Posted 5 hours ago Author Posted 5 hours ago "I can't watch a 15 minute video." That's a shame since the instructor can explain it much, much better than I can and you can and seeing him use the system could possibly provide an idea or two in the process ... Quote Creating professional 2D and 3D content is my passion! Monkey Frog Studio
Josh Posted 5 hours ago Posted 5 hours ago Is there anything else I am missing? We're just talking about the object orientation right? These things literally feel like this to me: Quote Let's build cool stuff and have fun.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.