Goregonzola Posted February 7, 2021 Share Posted February 7, 2021 (edited) Greetings! Sooo, I was thinking about giving my custom character a backback as a starting item, but I'm not sure if it's ever possible, as backpacks can't be put into inventories. How is this works? A simple "backpack" to the starting item list does the trick, or is it a lot more difficult? Thanks in advance! Edited February 9, 2021 by BillTheCipher Link to comment https://forums.kleientertainment.com/forums/topic/126831-starting-backpack-for-custom-character/ Share on other sites More sharing options...
Combustiblemon Posted February 7, 2021 Share Posted February 7, 2021 Just adding 'backpack' in starting items will work, because I did it long ago. Link to comment https://forums.kleientertainment.com/forums/topic/126831-starting-backpack-for-custom-character/#findComment-1426579 Share on other sites More sharing options...
Goregonzola Posted February 7, 2021 Author Share Posted February 7, 2021 @Combustiblemon I've just tried it out: The backpack do appeared in the character selection screen as starting item, but the character doesn't had it when it spawned. Am I missing something here? Link to comment https://forums.kleientertainment.com/forums/topic/126831-starting-backpack-for-custom-character/#findComment-1426591 Share on other sites More sharing options...
Combustiblemon Posted February 7, 2021 Share Posted February 7, 2021 (edited) Well, somehow I remember I did start with backpacks, but I can't test scripts now, so I just have to guess: local function _OnNewSpawn() SpawnPrefab("backpack") end Add this function to your character.lua. maybe this will work? Edited February 7, 2021 by Combustiblemon Link to comment https://forums.kleientertainment.com/forums/topic/126831-starting-backpack-for-custom-character/#findComment-1426595 Share on other sites More sharing options...
Goregonzola Posted February 8, 2021 Author Share Posted February 8, 2021 @Combustiblemon No luck with it, even with the function added Link to comment https://forums.kleientertainment.com/forums/topic/126831-starting-backpack-for-custom-character/#findComment-1426867 Share on other sites More sharing options...
Combustiblemon Posted February 8, 2021 Share Posted February 8, 2021 Then try add this function: local function SpawnBack() SpawnPrefab("backpack") end and this line to common_postinit or master_postinit I guess? inst._onnewspawn = SpawnBack() Link to comment https://forums.kleientertainment.com/forums/topic/126831-starting-backpack-for-custom-character/#findComment-1426919 Share on other sites More sharing options...
Goregonzola Posted February 8, 2021 Author Share Posted February 8, 2021 @Combustiblemon This coding spawned a backpack in a random place in the world Link to comment https://forums.kleientertainment.com/forums/topic/126831-starting-backpack-for-custom-character/#findComment-1426977 Share on other sites More sharing options...
DecDuck Posted February 9, 2021 Share Posted February 9, 2021 Make a function to spawn a prefab into the world and then either equip it or move it near the player 1 Link to comment https://forums.kleientertainment.com/forums/topic/126831-starting-backpack-for-custom-character/#findComment-1427140 Share on other sites More sharing options...
Wonderlarr Posted February 9, 2021 Share Posted February 9, 2021 (edited) On 2/8/2021 at 7:36 AM, BillTheCipher said: @Combustiblemon This coding spawned a backpack in a random place in the world In my mod, I use a line of code in my character's prefab file to make her spawn with a Hat on, maybe the same can be done with the backpack slot. Try having this function run when your character spawns in. That should be the function OnNewSpawn if you used the character template. local function SpawnWithStuff(inst) local backpack = SpawnPrefab("backpack") inst.components.inventory:Equip(backpack) end If this doesn't work, an easy option may be to make your own version of the backpack that can also act as an inventory item, specifically so you can properly spawn with it. Edited February 9, 2021 by TheSkylarr 1 Link to comment https://forums.kleientertainment.com/forums/topic/126831-starting-backpack-for-custom-character/#findComment-1427455 Share on other sites More sharing options...
Goregonzola Posted February 10, 2021 Author Share Posted February 10, 2021 @TheSkylarr Thanks for the tip! I'll experiment with it Link to comment https://forums.kleientertainment.com/forums/topic/126831-starting-backpack-for-custom-character/#findComment-1427578 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