Alienhead Posted 8 hours ago Share Posted 8 hours ago I was doing some thinking on the topic brought up in discord the other day it has me rather bothered... regarding calling to many components. I started looking over my own project and realized that 80% of the time component is out of range. Now I do a SetHidden(true) when that happens but If I understand correctly the update() and hooks() still get called? I have a simple solution, self.entity:DeactivateComponenet(true/false) For the 100's of objects on a map that arent even being used, seen or reacted with - this seems like a great waste of resource to me. We could simply turn the component OFF so the engine don't make calls to it - then turn it back on when it's in range or whatever the designer sees fit. I personally, can see major room for optimization with such an ability Quote Alienhead Components and Software Link to comment Share on other sites More sharing options...
Alienhead Posted 8 hours ago Author Share Posted 8 hours ago Let me through out an example. I have a map with a terrain on it, and plenty of stuff going on, underneath theres a tunnel that goes to a large cave area. Well inside the cave area I have hundreds of scripts/components for doors, particles, etc.etc.. Now these are constantly getting called ( update() or whatever ) and Im not even in the cave. It would be easy to build a custom function that checks player distance to component and then re-activate the components when I enter the cave.. Just an example... but .. Quote Alienhead Components and Software Link to comment Share on other sites More sharing options...
Josh Posted 7 hours ago Share Posted 7 hours ago This is something I have considered. Something like Entity::SetUpdateRange(), and you would need another command to indicate where the "center" of the update region is. It can't just be the camera position, because multiple cameras are supported. 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...
Alienhead Posted 7 hours ago Author Share Posted 7 hours ago That would work to, or just the plain vanilla option to deactivate and reactivate the component on our own, I myself would prefer creating my own function to handle on/off's... for different scenarios. Quote Alienhead Components and Software Link to comment Share on other sites More sharing options...
Alienhead Posted 7 hours ago Author Share Posted 7 hours ago I have a solution to do this now, but I did not want to start implementing it if there is a upcoming engine remedy. Quote Alienhead Components and Software Link to comment Share on other sites More sharing options...
Josh Posted 7 hours ago Share Posted 7 hours ago I think it might work right now if you just do this: function thing:DisableUpdate() self.temp = self.Update self.Update = nil end function thing:EnableUpdate() if self.temp ~= nil then self.Update = self.temp end end 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...
Alienhead Posted 7 hours ago Author Share Posted 7 hours ago What about other hooks ? Quote Alienhead Components and Software Link to comment Share on other sites More sharing options...
Alienhead Posted 7 hours ago Author Share Posted 7 hours ago My idea was to save it to a table on mapload, complete remove it from the scene, then monitor the table and positioning and load it back in when ready. Quote Alienhead Components and Software Link to comment Share on other sites More sharing options...
Alienhead Posted 7 hours ago Author Share Posted 7 hours ago But now I think about it, thats not really good... some components need to accumlate variables and datas and such.. Just need to freeze the entire module and go about your business ! Quote Alienhead Components and Software 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.