• Prop Shifting / Angle Math
    2 replies, posted
I'm attempting to create my own prop-spawning method, as of right now a 'Ghost-Prop' spawns in-front of the the player and moves around. However, I need to make it so the player is able to rotate the prop just as if he was holding the prop with a Phys-Gun. I have little to no-understanding as how to manipulate the angles based on the mouse position and would appreciate any help. [lua] --Players Ghost prop is ply.GhostProp, it's only drawn on the client but exists server-side. --The following function is only ran when a players NWString is equal to the ToolType "Build", and when the active weapon is Strong_Tool. function Stronghold_DoGhost(ply) local pos = ply:GetShootPos() local ang = ply:GetAimVector() local td = {} td.start = pos td.endpos = pos+(ang*200) td.filter = ply td.mask = SOLID_BRUSHONLY local s = util.TraceLine(td).HitPos if(s == nil) then return end if(ply.GhostProp == nil or not ply.GhostProp:IsValid()) then local ent = ents.Create("Stronghold_GhostProp") s:Add(Vector(0,0,-2)) ent:SetPos(s) ent:SetModel(Stronghold.Props[ply:GetNWInt("Strong_SelectedProp")].Mdl) ent:Spawn() ent:GetPhysicsObject():EnableMotion(false) r,g,b,a = ent:GetColor() ent:SetColor(r,g,b,150) ply.GhostProp = ent else ply.GhostProp:SetPos(s) end end concommand.Add("Stronghold_DoGhost", Stronghold_DoGhost) [/lua]
Er, since I need this too, when you fix it, could you give me the code? I'm actually using it to revive a gamemode that was abandoned by its developer. EDIT : Oh wait, I found the Lua version of the physgun on gmod.org. I'll get the rotation out of it. This seems to be the rotation function. If someone could fix it to work, then.. [lua] if self.Weapon.HitEntity and self.Weapon.HitEntity:IsValid() then local physobj = self.Weapon.HitEntity:GetPhysicsObjectNum(self.Weapon.HitBone) if physobj:IsValid() then physobj:Wake() end if self.Owner:KeyDown(IN_USE) then if !self.Weapon.RotationLock then self.Weapon.RotationLock = self.Owner:EyeAngles() local rp = RecipientFilter() rp:AddPlayer(self.Owner) umsg.Start("freeze", rp) umsg.Bool( true ) umsg.Angle( self.Weapon.RotationLock ) umsg.End() end end [/lua]
Bump.
Sorry, you need to Log In to post a reply to this thread.