Creating Ice Effect?

I can’t seem to find a way to replicated a player sliding on ice, it would be something similar to sv_friction 0.

Task at hand:
Trying to get a player to slide across my entitie as if it were ice. I have the entitie coded I just can’t figure out a way to do this.

Any pointers on this would be greatly appreciated!

Physical Properties Tool

Syntax: construct.SetPhysProp(ply, ent, BoneID, Bone, PhysObj)

Example: construct.SetPhysProp(self:GetOwner(), Ent, Bone, nil, {GravityToggle = gravity, Material = material})

Thanks a bunch dude!


It’s returning an error and I can’t figure out why.


function ENT:Touch( ent )

    if ( isTouching ) then
        construct:SetPhysProp( self:GetOwner() , self.Entity, nil, nil,  { GravityToggle = false, Material = "ice" } )


[ERROR] lua/includes/modules/construct.lua:20: Tried to use a NULL entity!
  1. GetPhysicsObjectNum - [C]:-1
   2. SetPhysProp - lua/includes/modules/construct.lua:20
    3. unknown - gamemodes/hns/entities/entities/ice/init.lua:44

Looks like your isTouching is global, look into that. And use self, not self.Entity. But your actual problem is that you didn’t specify any bone. Try 0 for that first nil, leave the second one.

construct is a library, call it with construct.functionName not construct:functionName

Well thank you guys that seemed to have fixed the issue although it is throwing a new error that I don’t know how to fix.

function ENT:Touch( ent )

    if ( isTouching ) then
        construct.SetPhysProp( self:GetOwner() , self, 0, nil,  { GravityToggle = false, Material = "ice" } )

SetPhysProp: Error applying attributes to invalid physics object!

This is the code for the construct functions

[lua] if ( !Bone ) then

		Bone = Entity:GetPhysicsObjectNum( BoneID )
		if ( !Bone || !Bone:IsValid() ) then 
			Msg("SetPhysProp: Error applying attributes to invalid physics object!

return end


It is trying to get bone 0 and failing. Try changing your 0 to 1 and see if it helps.

Hi, you’ve been heavily misinformed.

First of all, the “construct” functions are helper functions for GMod tools and you shouldn’t be using them like that at all. Forget about them.
A much simpler way to set the material property of your entity is this:

[lua]local phys = self:GetPhysicsObject()

Also, this should be done in your entity’s Initialize function. You set the material once, and it’s going to keep it forever, no need to set the material every time something touches it.

Oh also, unless something has changed in the past few months, it’s not going to work!
Changing the physical properties of an entity unfortunately doesn’t affect the way players walk on them.

Apparently there’s another property which is independent from the physics material, and as far as I know there’s no way to change it in Lua. If you want to check this, try to replace “ice” with “slipperymetal”, it’s the material which is used by the PHX monorail props, which are extremely slippery when you walk on them. If it works, then that’s good. If it doesn’t, it probably means what you’re trying to do is impossible at the moment.

Actually, it would be possible to modify the player’s movement hooks and simulate friction (or the lack thereof), but that would be completely out of reach if you’re still a Lua beginner.

Well thanks for clearing things up Killburn with using construct functions like that. So this pretty much impossible if slipperymetal doesn’t work?

Instead of changing the physical properties of the entity the model that is spawned. Could we change the physical property of the Player when touching the entity? Sorry If this is absolutely retarded I am new to coding as I’m sure you can tell.

If you can attach it to a player I think it might work because when I attach physprop Ice to an entity and I throw it, it keeps sliding.

Anyway thanks for the info and sorry for being a retard :stuck_out_tongue: