lyall_f Posted April 8, 2014 Share Posted April 8, 2014 I have programmed an npc to spawn at the start of the game from the player however the game is making two instead of one. Is there any way I can make the game only permit on of this kind of entity to exist? Link to comment https://forums.kleientertainment.com/forums/topic/34475-duplication-issue/ Share on other sites More sharing options...
Heavenfall Posted April 8, 2014 Share Posted April 8, 2014 If there already is one, don't spawn another one. You can cycle through global variable Prefabs to find out what already exists. Link to comment https://forums.kleientertainment.com/forums/topic/34475-duplication-issue/#findComment-447999 Share on other sites More sharing options...
lyall_f Posted April 8, 2014 Author Share Posted April 8, 2014 If there already is one, don't spawn another one. You can cycle through global variable Prefabs to find out what already exists. inst:AddComponent("childspawner")inst.components.childspawner.childname = "westy"inst.components.childspawner:StartSpawning()inst.components.childspawner.maxchildren = 1 if inst.components.leader then local x,y,z = inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x,y,z, 100, {"westy"}) for k,v in pairs(ents) do if v.components.follower then inst.components.leader:AddFollower(v) end end for k,v in pairs(inst.components.leader.followers) do if k:HasTag("westy") and k.components.follower then k.components.follower:AddLoyaltyTime(99999) end end endend This is in my character file, it spawns the npc and is only allowed to make one yet two spawn. I have no clue why. Link to comment https://forums.kleientertainment.com/forums/topic/34475-duplication-issue/#findComment-448009 Share on other sites More sharing options...
Heavenfall Posted April 8, 2014 Share Posted April 8, 2014 Both childspawner component and your following function are set to spawn a westy. Childspawner is likely delayed, so first you get the function and then the childspawner one. Anyway, you don't need both. Link to comment https://forums.kleientertainment.com/forums/topic/34475-duplication-issue/#findComment-448011 Share on other sites More sharing options...
lyall_f Posted April 8, 2014 Author Share Posted April 8, 2014 Thanks. Link to comment https://forums.kleientertainment.com/forums/topic/34475-duplication-issue/#findComment-448012 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now