• Freezing a PhysObj but allowing gravity gun pickup.
    1 replies, posted
I'm trying to make an entity not move when it spawns, but when the entity is picked up with the gravity gun it moves freely. So far I have tried PhysObj:Sleep(), but had no luck, and the closest I've got to it is calling PhysObj:EnableMotion( false ), but that doesn't allow physgun pickup. Here is my code: [lua] local flag = ents.Create( ctf.Ent ) flag:SetPos( ctf.MapData[ game.GetMap() ][ "flag" ] ) flag:Spawn() local flagPhys = flag:GetPhysicsObject() if IsValid( flagPhys ) then flagPhys:Sleep() -- Doesn't seem to be working flagPhys:EnableMotion( false ) -- Works but doesn't allow gravgun pickup print( "flagPhys is valid." ) else print( "flagPhys wasn't valid!" ) end [/lua] When I use either of the two functions I get "flagPhys is valid" printed to my console.
GMod itself is filled with examples, you just need to do a few clicks, I know it's hard, but please try it next time before asking. [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/entities/entities/prop_effect.lua[/url]
Sorry, you need to Log In to post a reply to this thread.