Slimwaffle Posted July 12, 2018 Share Posted July 12, 2018 I am so happy I got this working I am going to share it with you guys. These scripts will allow you to move items around in game. Enjoy The first script is here; --Generic Item Script function Script:Start() self.entity:SetKeyValue("type","item") pos = self.entity:GetPosition() end function Script:UpdateWorld() end Now the Second Script to actually move the item; --Script to move Item Script.camPick = false Script.radius = 1 function Script:Start() self.player = self.entity:GetParent() self.camera = self.player.script.camera end function Script:UpdateWorld() local pickInfo = PickInfo() local mouse = window:GetMousePosition() if self.camera:Pick(mouse.x, mouse.y, pickInfo, self.radius, true,2) then if pickInfo.entity:GetKeyValue("type") == "item" then self.camPick = true end else self.camPick = false end local pickInfo = PickInfo() local mouse = window:GetMousePosition() if self.camera:Pick(mouse.x, mouse.y, pickInfo, self.radius, true,2) then pickInfo.entity:SetPickMode(Entity.PolygonPick) dist = self.camera:GetDistance(pickInfo.entity,false) if dist >= 20 then self.camPick = false end if self.camPick == true then if pickInfo.entity:GetKeyValue("type") == "item" then if window:KeyDown(Key.Q) then --UnProject mouse coordinates from screen space to world space and position the box there local p = window:GetMousePosition() p.z = 3 --distance in front of the camera to project to p = self.camera:UnProject(p) pickInfo.entity:SetPosition(p) end end end end end 1 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.