Garry's Mod Wiki

Revision Difference

constraint.Keepupright#528781

<function name="Keepupright" parent="constraint" type="libraryfunc"> <description> Creates a keep upright constraint. <note>This function only works on prop_physics or prop_ragdoll.</note> </description> <realm>Server</realm> <file line="631">lua/includes/modules/constraint.lua</file> <args> <arg name="ent" type="Entity">The entity to keep upright</arg> <arg name="ang" type="Angle">The angle defined as "upright"</arg> <arg name="bone" type="number">The bone of the entity to constrain (0 for boneless)</arg> <arg name="angularLimit" type="number">Basically, the strength of the constraint</arg> </args> <rets> <ret name="" type="Entity">The created constraint, if any or false if the constraint failed to set</ret> </rets> </function> <example> <description>From properties/keep_upright.lua (the right click menu)</description> <code>constraint.Keepupright( ent, Phys:GetAngles(), 0, 999999 )</code>⤶ <description>Adds a console command that makes whatever prop the player is looking at to be kept upright.</description> <code>concommand.Add( "keep_upright",function( ply, cmd, args ) local tr = ply:GetEyeTrace()⤶ ⤶ local ent = tr.Entity⤶ if ( !IsValid( ent ) ) then return end⤶ ⤶ constraint.Keepupright( ent, ent:GetAngles(), tr.PhysicsBone, 999999 )⤶ end )</code>⤶ </example>