• constraint.Keepupright not working?
    4 replies, posted
I remember trying to use this constraint before many time and only succeeded once but I cant remember how I did it.. Anyways this gives me no errors and doesn't work either. Here is the Initialize function from init.lua [code] function ENT:Initialize() self:SetModel( "models/props_lab/crematorcase.mdl" ) self:PhysicsInit( SOLID_VPHYSICS ) self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLID_VPHYSICS ) self:SetAngles( Angle(0,0,180) ) self:Activate() constraint.Keepupright( self, Angle(0,0,180), 0, 500 ) phys = self:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() end end [/code]
[CODE]constraint.Keepupright( ent, Phys:GetAngles(), 0, 999999 )[/CODE] Have you tried using the default wiki? The lower the 3rd argument the lesser kept up it is. And I am talking about going to 500,000 or some shit, 500 will do nothing.
[B]BUMP[/B] (Still dont know how to do this ;_;) [QUOTE=JacobsReturn;52463051][CODE]constraint.Keepupright( ent, Phys:GetAngles(), 0, 999999 )[/CODE] Have you tried using the default wiki? The lower the 3rd argument the lesser kept up it is. And I am talking about going to 500,000 or some shit, 500 will do nothing.[/QUOTE] I tried what you said and it doesnt work. .-.
[code] --[[---------------------------------------------------------------------- Keepupright( ... ) Creates a KeepUpright constraint ------------------------------------------------------------------------]] function Keepupright( Ent, Ang, Bone, angularlimit ) if ( !CanConstrain( Ent, Bone ) ) then return false end if ( Ent:GetClass() != "prop_physics" && Ent:GetClass() != "prop_ragdoll" ) then return false end if ( !angularlimit or angularlimit < 0 ) then return end local Phys = Ent:GetPhysicsObjectNum(Bone) -- Remove any KU's already on entity RemoveConstraints( Ent, "Keepupright" ) onStartConstraint( Ent ) local Constraint = ents.Create( "phys_keepupright" ) Constraint:SetAngles( Ang ) Constraint:SetKeyValue( "angularlimit", angularlimit ) Constraint:SetPhysConstraintObjects( Phys, Phys ) Constraint:Spawn() Constraint:Activate() onFinishConstraint( Ent ) AddConstraintTable( Ent, Constraint ) local ctable = { Type = "Keepupright", Ent1 = Ent, Ang = Ang, Bone = Bone, angularlimit = angularlimit } Constraint:SetTable( ctable ) -- -- This is a hack to keep the KeepUpright context menu in sync.. -- Ent:SetNWBool( "IsUpright", true ) return Constraint end duplicator.RegisterConstraint( "Keepupright", Keepupright, "Ent1", "Ang", "Bone", "angularlimit" ) [/code] Here's the line that's causing your code to fail: [code] if ( Ent:GetClass() != "prop_physics" && Ent:GetClass() != "prop_ragdoll" ) then return false end [/code] You're using a custom entity.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/constraint/Keepupright]constraint.Keepupright[/url] It says it works only with props and ragdolls, dang, why people dont read the wiki first?
Sorry, you need to Log In to post a reply to this thread.