if picker is something without inventory component, the product will be spawned but skip the code for location, so it's at (0,0,0).
And this issue has actually happened a lot, for example when alterguardian_laser( or antlion_sinkhole) hit the reeds.
Here's the relative code: (I think the code can be better if picker is TheWorld and the follow-up code to manually spawn the products is unnecessary . Oops there are already a large amount of duplicate codes in other files)
elseif collapsible_entity.components.pickable ~= nil and collapsible_entity.components.pickable:CanBePicked() and not collapsible_entity:HasTag("intense") then local num = collapsible_entity.components.pickable.numtoharvest or 1 local product = collapsible_entity.components.pickable.product collapsible_entity.components.pickable:Pick(inst) -- only calling this to trigger callbacks on the object if product ~= nil and num > 0 then local ce_x, ce_y, ce_z = collapsible_entity.Transform:GetWorldPosition() for i = 1, num do SpawnPrefab(product).Transform:SetPosition(ce_x, 0, ce_z) end end
Here's a part of Pickable:Pick
loot = SpawnPrefab(self.product) if loot ~= nil then if loot.components.inventoryitem ~= nil then loot.components.inventoryitem:InheritWorldWetnessAtTarget(self.inst) end if self.numtoharvest > 1 and loot.components.stackable ~= nil then loot.components.stackable:SetStackSize(self.numtoharvest) end if inventorypicker then picker:PushEvent("picksomething", { object = self.inst, loot = loot }) picker.components.inventory:GiveItem(loot, nil, pt) elseif worldpicker then loot.Transform:SetPosition(pt:Get()) end end
And Here's the video to reproduce that:
Steps to Reproduce
follow the video' steps
- 1
- 1
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