• How the actual hell are buttons welded?
    0 replies, posted
I'm trying to make an addon that includes my own button entities. To place these buttons, I'm using a modified version of the sandbox button STool. Everything is working fine apart from getting the buttons to attach to the wall correctly. Default gmod buttons a) have collisions and b) are fixed firmly to the wall. Buttons I place with my STool for some reason all nocollided. Commenting out all the code that makes the nocollided welds them to the wall but so weakly that they decide to take a trip into the next room on the slightest touch. In the default button code is this (lines 57 onwards): [CODE]undo.Create( "Button" ) undo.AddEntity( button ) if ( worldweld && trace.Entity != NULL ) then local weld = constraint.Weld( button, trace.Entity, 0, trace.PhysicsBone, 0, 0, true ) if ( IsValid( button:GetPhysicsObject() ) ) then button:GetPhysicsObject():EnableCollisions( false ) end button:SetCollisionGroup( COLLISION_GROUP_WORLD ) button.nocollide = true ply:AddCleanup( "buttons", weld ) undo.AddEntity( weld ) end undo.SetPlayer( ply ) undo.Finish()[/CODE] What kind of fucking magic is going on here? If the buttons have a valid collision model then make them nocollided? Isn't that the opposite of what should happen? How do default buttons manage to have a collision model and collide with the player if this code seemingly makes any prop with a valid collision model nocollided? And why do my buttons seem to attach themselves with pritt stick instead of the industrial grade superglue the default buttons use? [editline]8th July 2017[/editline] Ok, I think I've figured out what the issue is. Correct me if I'm wrong but I believe that an entities physics object only exists if it is a physics prop in the world, rather than just being static and having a hitbox as I previously assumed. Therefore a button on a wall can have a hitbox without having a physics object. Now the question is, how do I make it so that my entities don't have a physics object from the start? I've removed phys:wake() from my ENT:Initialise but my entities still have a physics object when spawned.
Sorry, you need to Log In to post a reply to this thread.