onaid Posted May 16, 2016 Share Posted May 16, 2016 hi all having a little trouble with removing / drop a weapon. basically i would like my player to walk through a trigger and have it remove the weapon so player no longer has the weapon if that makes sense. i have tried attaching weapon pickup lua to a invisible box with a blank prefab but to no avail https://drive.google.com/open?id=0BxWM6ILP8Pf9Ml8yX2NjdzQ3QUU above is the project link test.rar thank you in advance Quote Link to comment Share on other sites More sharing options...
martyj Posted May 16, 2016 Share Posted May 16, 2016 This is roughly how I do it. C++ --------------------- // Place in Start() function for instance caching Entity* leftHand = playerModel->FindChild("LeftHand_OrWhateverMyModelSays"); // Wielding Model* leftHandItem = Model::Load("SomePath") leftHandItem ->SetParent(leftHand); // Unwielding leftHandItem ->SetParent(NULL); // DELETE if not using again! Lua? --------------- // Place in Start() function for instance caching self.leftHand = playerModel:FindChild("LeftHand"); // Weidling self.leftHandItem = Model:Load("SomePath"); self.leftHandItem:SetParent(self.leftHand) // Unweild self.leftHandItem:SetParent(NULL); // DELETE if not using again! Btw I think your map is missing some details. It doesn't contain any player object. Are you using the FPSPlayer.lua script for your player? Quote Link to comment Share on other sites More sharing options...
onaid Posted May 16, 2016 Author Share Posted May 16, 2016 Hi Marty j , thanks for your reply yep i am using the fpsplayer.lua script for player , so i pasted the script you gave me in the fps player.lua im not sure if i got it totaly right as i get this error also there are no childen in the fps player model ? i s this what you mean when you say there is no player object ? so i cant choose to findchild lefthand sorry pretty newb at script , thank you for your help Quote Link to comment Share on other sites More sharing options...
Roland Posted May 16, 2016 Share Posted May 16, 2016 The error is caused by using c++ style comments // in Lua. Replace those // with --. Regarding the player object. It's the object you attached the script to. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
onaid Posted May 16, 2016 Author Share Posted May 16, 2016 thanks Roland now i get this not sure if this helps but this is what i had in my head was to change the FPSplayer.lua so i could enable / disable weapon again sorry newb at script Quote Link to comment Share on other sites More sharing options...
Roland Posted May 16, 2016 Share Posted May 16, 2016 The player model is the entity the script is attached to, so it would be self.entity:FindChild. I'm at my phone now so I can't give any more detailed help. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
onaid Posted May 17, 2016 Author Share Posted May 17, 2016 thanks for your help Roland but im not sure where to change the script would self.entity:FindChild replace playerModel:FindChild ? also the FPSplayer model has no children in the scene tab ? Quote Link to comment Share on other sites More sharing options...
Josh Posted May 17, 2016 Share Posted May 17, 2016 If you look at the Script:AddWeapon() function, basically you've got to reverse what that does: function Script:AddWeapon(weapon) if weapon.index==nil then weapon.index=1 end if self.weapons[weapon.index]==nil then self.weapons[weapon.index]=weapon self.weapons[weapon.index].player = self self.weapons[weapon.index].entity:SetParent(self.weapontag) self.weapons[weapon.index].entity:SetPosition(self.weapons[weapon.index].offset) if self.weapons[weapon.index].rotation~=nil then self.weapons[weapon.index].entity:SetPosition(self.weapons[weapon.index].rotation) end self.weapons[weapon.index].entity:Hide() if weapon.index>self.currentweaponindex then self:SelectWeapon(weapon.index) end if self.sound.pickupweapon~=nil then self.sound.pickupweapon:Play() end return true end return false end 2 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...
onaid Posted May 23, 2016 Author Share Posted May 23, 2016 http://www.leadwerks.com/werkspace/page/api-reference/_/entity/entityhide-r181 can i do somthing with this ? Quote Link to comment Share on other sites More sharing options...
onaid Posted June 3, 2016 Author Share Posted June 3, 2016 sorry guys just total newb when it comes to script super keen to learn just need some help here Quote Link to comment Share on other sites More sharing options...
onaid Posted June 3, 2016 Author Share Posted June 3, 2016 ok guys all thanks for your help , big thanks to the living legend Paul Thomas who totally got this sorted, mate you are a bloody champion. here is script for fps player.lua if you want to do the same. http://pastebin.com/D12H7Qbi Paul Thomas living legend Quote Link to comment Share on other sites More sharing options...
Paul Thomas Posted June 3, 2016 Share Posted June 3, 2016 You're welcome man. I'm glad I was able to help. Quote 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.