Hey, I want the GravGun to Unfreeze specific entities when left clicked. This is what I got so far:
[CODE]
hook.Add( "GravGunPunt", "UnfreezeGravGunnedEntities", function( ply, ent )
if table.HasValue( pickupable, ent:GetClass():lower() ) then
local phys = ent:GetPhysicsObject()
if ( IsValid( phys ) ) then
phys:EnableMotion( true )
end
end
end )
[/CODE]
It is not working, so does anybody know what I'm doing wrong?
[editline]27th September 2015[/editline]
The table is defined above
If the object unfreezes once you touch it with any physical object (after punting the frozen object with the gravgun), then your problem is just that you need to call phys:Wake() after phys:EnableMotion()
[editline]27th September 2015[/editline]
EnableMotion(true/false) dictates if force is allowed to be applied to an object (be it gravity or object-to-object physics)
Setting it to true means it can accept forces, but the game engine optimizes by not considering gravity until an object touches it (or until Wake is called).
[QUOTE=bitches;48773117]If the object unfreezes once you touch it with any physical object (after punting the frozen object with the gravgun), then your problem is just that you need to call phys:Wake() after phys:EnableMotion()
[editline]27th September 2015[/editline]
EnableMotion(true/false) dictates if force is allowed to be applied to an object (be it gravity or object-to-object physics)
Setting it to true means it can accept forces, but the game engine optimizes by not considering gravity until an object touches it (or until Wake is called).[/QUOTE]
This make sense, thanks! :)
Just tested it and it seems to work just fine. Thanks for your help! :)
Sorry, you need to Log In to post a reply to this thread.