Mikalaj Posted October 14, 2014 Share Posted October 14, 2014 Hello, I have the next problem, maybe someone can help me. I want to create a weapon prefab. I got mdl file with all the animations. But that model was oriented differently than standard FPSPlayer.lua expects. So I created a pivot point with appropriate orientation and attached the whole model to this point.I have attached a script no to the top level pivot point but to the weapon model that is a child of a pivot point. Save scene as prefab. To the FPSPlayer.lua script in another scene I have attached this prefab as a weapon. And when I start a game Script:Start in the prefab weapon is not called leaving uninitialized some parameters that lately causes errors. So I have several questions. Is start method is some special method? What conditions should be met to make Start called? What is the best way to initialize parameters in the prefab? Thanks. Quote Link to comment Share on other sites More sharing options...
Genebris Posted October 14, 2014 Share Posted October 14, 2014 (edited) I thought start is called for all entities, but if it's not, you can just call it yourself from player start function for example. Find where weapon prefab is loaded in player script and then call weapon's start. I have just came across the same problem so I added start call myself: w=Prefab:Load("prefabs/weapons/"..self.equipment["weapon"]..".pfb") w:GetChild(0).script:Start() Edited October 15, 2014 by Genebris Quote Link to comment Share on other sites More sharing options...
Mikalaj Posted October 15, 2014 Author Share Posted October 15, 2014 Thanks, Genebris. That also worked for me. Seem that documentation differs from reality. http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/prefab/prefabload-r622 states "When the prefab is loaded, any entities in the hierarchy with a script attached to them will have the Start() function called." Quote Link to comment Share on other sites More sharing options...
Josh Posted October 16, 2014 Share Posted October 16, 2014 Add Map::LoadScripts to the flags parameter. I updated the documentation a bit and added a comment below. 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...
Rick Posted October 16, 2014 Share Posted October 16, 2014 static Entity* Load(const std::string& path, int flags=LoadScripts, const uint64_t fileid=0) Isn't that the default value already? Quote Link to comment Share on other sites More sharing options...
beo6 Posted October 16, 2014 Share Posted October 16, 2014 According to the documentation page i would also think that scripts are loaded already by default. Quote Link to comment Share on other sites More sharing options...
Josh Posted October 16, 2014 Share Posted October 16, 2014 You're right. 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.