• spawn welded props
    1 replies, posted
How could one spawn welded props with lua? [lua] local tr = pl:GetEyeTrace() -- tr now contains a trace object local ent = ents.Create("npc_turret_floor") -- This creates our npc entity ent:SetPos(tr.HitPos) -- This positions the npc at the place our trace hit. ent:SetCurrentWeaponProficiency( WEAPON_PROFICIENCY_PERFECT ) ent:Spawn() -- This method spawns the npc into the world ent:Activate() [/lua]
If you're trying to weld your turret to whatever you're aiming at, use [url=http://wiki.garrysmod.com/page/Libraries/constraint/Weld][i]constraint.Weld[/i][/url]. You can use information from your trace result ([i]TraceRes.Entity[/i] and [i]TraceRes.PhysicsBone[/i]) to define the entity and bone number to weld to. Alternatively, if you just want the turret to be stationary, have a look at [url=http://wiki.garrysmod.com/page/Classes/Entity/SetMoveType][i]Entity.SetMoveType[/i][/url].
Sorry, you need to Log In to post a reply to this thread.