• Trying to spawn entities relative to each other (duplicator)
    1 replies, posted
Hello! I'm trying to save and be able to spawn CEnts but have them appear like a normal dupe. So my problem is: I can save the props using duplicator.CopyEnts(), then on the clientside I want the user to be able to see where he's gonna place the props/dupe. So I wanted to spawn the props on the client-side and set their position relatively to the mouse position (Raycasted to get a world vector). But the position of the props are a bit weird. But then I get this, misplaced props. https://files.facepunch.com/forum/upload/113981/244c092b-3125-426a-93dd-cc17708335fe/hl2_0OCdqfQBIi.jpg Here's the breakdown of the code. That's how I get the props and save them for later --Get entities data local ent = ply:GetEyeTrace().Entity local dupe duplicator.SetLocalPos(ent:GetPos()) if constraint.HasConstraints(ent) then dupe = duplicator.CopyEnts(constraint.GetAllConstrainedEntities(ent)) else dupe = duplicator.CopyEntTable(ent) end duplicator.SetLocalPos(Vector(0,0,0)) --Saving prefab local name = args[1] or "unnamed prefab" name = name:lower():Replace(" ", "_") local filename = folder .. "/" .. name .. ".txt" local json = util.TableToJSON(dupe, true) file.Write(filename, json) That's how I preview them --Creating clientside props frame.csProps = {} for _,prop in pairs(v.Entities) do     local csent = ents.CreateClientProp(prop.Model)     frame.csProps[csent] = prop end --Moving the props relatively to the mouse pos function frame:Think()     local trace = {         start = EP.curPos,         endpos = EP.curPos + gui.ScreenToVector(gui.MousePos()) * 10000     }     local mpos = util.TraceLine(trace).HitPos     for prop,pdata in pairs(frame.csProps) do         local lpos = mpos - pdata.Pos - pdata.Mins --Local pos of entity         prop:SetPos(lpos)         prop:SetAngles(pdata.Angle)     end end Thanks for the help! Cheers!
not really enough info here to help you lol
Sorry, you need to Log In to post a reply to this thread.