• Entity Positioning
    0 replies, posted
I was messing around and trying out a new mechanic that I would like to use to create a gamemode. It is supposed to create props with models and position/angle offsets from a table where the position offset is based on the position of the first prop created. However, it is creating the 2nd prop in weird places not even near where it is supposed to be. [code] Msg("attempting to construct...\n") V = {} V.P = {"models/Combine_Helicopter/helicopter_bomb01.mdl","models/props_c17/FurnitureDrawer001a.mdl"} V.FO = {0,0} V.HO = {0,0} V.VO = {0,0} V.PA = {0,90} V.YA = {0,0} V.RA = {0,90} pl = player.GetByID(1) local tr = pl:GetEyeTrace() pl.SP = {} for k, v in pairs(V.P) do local ent = ents.Create("prop_physics") pl.SP[k]=ent ent:SetModel(v) if k == 1 then ent:SetPos(tr.HitPos + Vector(0,0,200)) else ent:SetPos(((pl.SP[1]:GetForward()*V.FO)-pl.SP[1]:GetPos())+((pl.SP[1]:GetRight()*V.HO)-pl.SP[1]:GetPos())+((pl.SP[1]:GetUp()*V.VO)-pl.SP[1]:GetPos())) end ent:SetAngles(Angle(V.PA[k],V.YA[k],V.RA[k])) ent:Spawn() ent:GetPhysicsObject():EnableMotion(false) end [/code] Fixed, GetForward/Right/Up only return the change so the final code line was : [code] if k == 1 then ent:SetPos(tr.HitPos + Vector(0,0,200)) else ent:SetPos(((pl.SP[1]:GetForward()*V.FO[k])+(pl.SP[1]:GetRight()*V.HO[k])+(pl.SP[1]:GetUp()*V.VO[k]))+pl.SP[1]:GetPos()) end [/code]
Sorry, you need to Log In to post a reply to this thread.