[QUOTE=blackops7799;19652826][b][url=wiki.garrysmod.com/?title=PhysObj.GetMass]PhysObj.GetMass [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b][/QUOTE]
That still returns 45k+ for me, i need the default mass, as it was when it was first spawned, i tried getting it when the entity is being created but the PhysObject is not valid at that point.
check out how the weight stool does it
I assume you're trying to have it return the weight of the prop as you're holding it. I guess you could run a constant background check to check the mass of props that you're looking at, and have it return whatever mass it had just before you grabbed the prop.
Here is how you do it: take the 45K+ value and subtract 45678 and bam, you have the mass. I had to do this for my E2 code.
[QUOTE=vexx21322;19658465]Here is how you do it: take the 45K+ value and subtract 45678 and bam, you have the mass. I had to do this for my E2 code.[/QUOTE]
What if it weighs more than 4322?
[QUOTE=shaftm;19658508]What if it weighs more than 4322?[/QUOTE]
The entire universe implodes and all life stops at once. :iiam:
Try the [url=http://wiki.garrysmod.com/?title=Gamemode.PhysgunPickup]PhysgunPickup[/url] hook.
[QUOTE=Kialtia;19652599]And there is no way of getting the original mass of the entity?[/QUOTE]
I'm no lua king but shouldn't this work?
try increasing the timer length if it doesn't
[CODE]
function GM:OnEntityCreated( prop )
timer.Simple(1,DefaultMass,prop)
end
function DefaultMass(prop)
prop.defaultMass = prop:GetPhysicsObject( ):GetMass()
end
[/CODE]
[QUOTE=shaftm;19654194]check out how the weight stool does it[/QUOTE]
The weight STool doesn't do anything special with the mass actually, it has the same problem.
[editline]12:08PM[/editline]
[QUOTE=vexx21322;19658465]Here is how you do it: take the 45K+ value and subtract 45678 and bam, you have the mass. I had to do this for my E2 code.[/QUOTE]
Hmm, i'll try this.
[editline]12:09PM[/editline]
[QUOTE=Jdeedler;19660301]I'm no lua king but shouldn't this work?
try increasing the timer length if it doesn't
[CODE]
function GM:OnEntityCreated( prop )
timer.Simple(1,DefaultMass,prop)
end
function DefaultMass(prop)
prop.defaultMass = prop:GetPhysicsObject( ):GetMass()
end
[/CODE][/QUOTE]
Most of the time i pickup a prop within a second of spawning it actually, so this code it somewhat useless.
[editline]12:27PM[/editline]
[QUOTE=Nevec;19659221]Try the [url=http://wiki.garrysmod.com/?title=Gamemode.PhysgunPickup]PhysgunPickup[/url] hook.[/QUOTE]
I just did this, seems to work a whole lot better, thanks.
[QUOTE=shaftm;19658508]What if it weighs more than 4322?[/QUOTE]
The game crashes.
Why do you need the mass when you are holding it? It resets the mass when you let go.
Sorry, you need to Log In to post a reply to this thread.