Dreikblack Posted September 4 Share Posted September 4 I'm not sure if it would be same for new objects with same component but in this case i made a prefab and copied it couple times In Load() i assign a pointer if it was not yet, but it is with first pointer in next component instances. I think something was changed in Ultra not too long time ago because i noticed this issue only recently in my game Expected: 3 assigns in 3 objects and 3 different values in result check in main. But have atm 1 assign due issue above and as result getting same value from same pointer: Example with prefab, map, main and component CompLoad&PointerIssue.zip Quote Link to comment Share on other sites More sharing options...
Josh Posted September 4 Share Posted September 4 Okay, so here is what is happening: The first time LoadPrefab is called in the scene load routine, the prefab file is loaded, and the Load method is run. The prefab stores the loaded entity in a NULL world, and then makes an instance of it and returns that instance. Every time LoadPrefab is called after that, and it detects the path is the same as the first call, another instance is of the prefab entity is returned. At the end of the LoadScene routine, each component in each entity in the scene has its Load method called. So three entities coming from one prefab means it is called once when the prefab is loaded, and then once for each entity in the scene. Perhaps the Load method should be skipped for prefabs in the scene, because that data is all supposed to come from the prefab. In that case, the Load method would be called once, and the Copy method would be called three times. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dreikblack Posted September 5 Author Share Posted September 5 4 hours ago, Josh said: Perhaps the Load method should be skipped for prefabs in the scene, because that data is all supposed to come from the prefab. What will happen if these entities will be saved with Map::Save for saving game state? Also second thing is that i create another class instance that tied to specific component instance (ai for unit in this case). I do it in Load to restore its state from Editor or save file. And this component member have a weak_ptr to component instance. In some cases Load results may depends on entity position and rotation (not sure if it's a case in my game atm). Probably it would be better not to skip Load(). I will try to handle my case manually in Copy(), even tho i have many unit based classes and calling parent class Copy is not an option because it seems to return Parent class from child *this Quote Link to comment Share on other sites More sharing options...
Josh Posted September 5 Share Posted September 5 I need to think about this. I have some ideas. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted September 6 Share Posted September 6 We will discuss this in tomorrow's meeting. I don't want to make any major changes to this until after my talk with Khronos on Monday. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dreikblack Posted September 7 Author Share Posted September 7 On 9/6/2024 at 8:38 PM, Josh said: We will discuss this in tomorrow's meeting. Most likely i will not attend it because it's a bit too late for me, but my position atm is not do Load() for prefab and do it only for its instances to avoid unintended behavior for game devs. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted September 8 Share Posted September 8 We did not get to it in the meeting, but my basic idea is this: Currently, LoadPrefab first loads a copy of the scene into the NULL world and stores it, then returns an instance of the root entity. Any time the same prefab is loaded again, a new instance of the root entity is returned. This is why the extra call to Load is happening, and why the Load method must be able to handle the situation where the world is NULL. (It technically should anyways, but I can understand if people skip that.) I could probably disable this behavior without much trouble. The other issue is that Entity::Instantiate copies flowgraph connections to the original entity. There is no way for Instantiate to know a flowgraph connection target is also being copied. This is why prefabs currently cannot store their own internal flowgraphic. My idea is to make LoadPrefab load the JSON and binary data, and then run the scene load routine each time the same prefab is loaded. This would solve both problems easily. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted September 11 Share Posted September 11 I have revised the way prefab loading works. The component::Load calls may be more inline with your expectations now: https://www.ultraengine.com/community/topic/61318-release-notes/page/22/#comment-311284 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dreikblack Posted September 12 Author Share Posted September 12 In my game and my example here i have Assert Failed error now at map load Quote Link to comment Share on other sites More sharing options...
Josh Posted September 12 Share Posted September 12 My scene that contains a prefab does not have this problem. Can you provide instructions on how to make this error occur in your project? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dreikblack Posted September 12 Author Share Posted September 12 In first post a zip with map, prefab and classes. In my game any map have this crash (load map or new game) Quote Link to comment Share on other sites More sharing options...
Dreikblack Posted September 12 Author Share Posted September 12 I can't even open map from game or this example in Editor - crash with Assert Failed error Quote Link to comment Share on other sites More sharing options...
Josh Posted September 12 Share Posted September 12 Oh okay, I did not realize you meant the same files. I see the problem... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted September 12 Solution Share Posted September 12 It's updated now for the fix for the problem. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
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.