. . . Posted October 22, 2017 Share Posted October 22, 2017 (edited) Hello, I have a problem which I don't know how to fix if someone can help me that'd really be great ! So here is my code Spoiler local function Find(inst) if inst.components.health:IsDead() or inst.jump == true or inst.swimming == true then return end local bump = math.random(1,2) local fx = SpawnPrefab("maxwell_smoke") local x, y, z = inst.Transform:GetWorldPosition() if bump == 1 then fx.Transform:SetPosition(x, y, z) fx.Transform:SetScale(.35,.40,.45) inst.SoundEmitter:PlaySound("dontstarve/common/stone_drop") ShakeAllCameras(CAMERASHAKE.VERTICAL,.5, .01, .05, inst, .01) inst.components.talker:Say(GetString(inst, "ANNOUNCE_FOUND")) SpawnPrefab("dirtpile").Transform:SetPosition(inst.Transform:GetWorldPosition()) end end --inside master_postinit inst:DoPeriodicTask(3, Find) so my character has chance to find a dirtpile everyday which he can get loot from the problem is when my character is not supposed to find a dirtpile, the maxwell smoke will spawn somewhere in a random point of a world always. In each new world it's a different area, but all stuff I spawn with "local x, y, z = inst.Transform:GetWorldPosition()" & "local fx = SpawnPrefab("maxwell_smoke")" that happens. I also have this problem I try to spawn a item for my character to wear when I press a key. local ic = act.target.components local wathgrithrhat = SpawnPrefab("wathgrithrhat") ic.inventory:Equip(wathgrithrhat) I don't know how to fix this or what is wrong, so I would really appreciate any sort of help someone can provide, thank you very much !! Thanks for looking into my problem, have a great day/night !! Edited October 25, 2017 by SuperDavid being stupid sux Link to comment https://forums.kleientertainment.com/forums/topic/83175-need-help-fixing-spawned-fxitems-spawn-at-random-point-in-world/ Share on other sites More sharing options...
. . . Posted October 25, 2017 Author Share Posted October 25, 2017 bump 1 Link to comment https://forums.kleientertainment.com/forums/topic/83175-need-help-fixing-spawned-fxitems-spawn-at-random-point-in-world/#findComment-966573 Share on other sites More sharing options...
Serpens Posted October 26, 2017 Share Posted October 26, 2017 (edited) please better describe what you want and what is happening. By looking at your code you check bump==1 after spawning the smoke. So of course everytime the function is called, the smoke will spawn, but only with your random chance, also the dirtpile will spawn. That is what you wrote. What should happen instead? edit: And I suggest to use my function for spawning something near someone/something: but first try to understand what the function does. It is not that hard and meanwhile you should be able to understand it Edited October 26, 2017 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/83175-need-help-fixing-spawned-fxitems-spawn-at-random-point-in-world/#findComment-967362 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