Help with setting an entities weight in script (not using the weight tool in game)

Alright so simple enough I would think, I want to change the weight of a spawned entity. My problem however doesn’t seem as easy as ENT:SetWeight and after sometime trying to search the net, I’ve had no luck. I would probably have better luck if the search for FacePunch wasn’t for mods only every time I thought maybe I can use it.

Anyone wanna give me a quick example so I can get this fixed?

Mass is the correct term for it when dealing with physics.

**[PhysObj.SetMass

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=PhysObj.SetMass)**

Ty, sir, very appreciated.

Thanks for the tip, but this doesn’t seem to work. What am I doing wrong? It may have something to do with self.Entity:GetPhysicsObject instead of self:GetPhysicsObject(), since that’s the only thing different from the wiki page.

[lua]
function ENT:Initialize()
self.On = false
self.Entity:SetModel(“models/car/1.mdl”)
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)

local phys = self.Entity:GetPhysicsObject()

if (phys:IsValid()) then

    phys:Wake()

end
phys:SetMass( 2000 )

end
[/lua]

change your ‘local phys = self.Entity:GetPhysicsObject()’ to ‘local phys = self:GetPhysicsObject()’
That’s whats working for me.

I believe its due to the ‘self’ already realizing itself as an entity (could be wrong, just my theory)

For a start self.Entity is deprecated, just use self instead.

You should also set the mass inside your IsValid function, one last thing which state are you running this code in? (Client/Server?)

Server.