Jump to content

Recommended Posts

Posted

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.

Posted (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 by Genebris
Posted

Add Map::LoadScripts to the flags parameter. I updated the documentation a bit and added a comment below.

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...