Disabling motion

Hey guys,
I’m spawning a turret and need to totally disable motion, so that it absolutely can’t be moved. I have tried turret:EnableMotion(false) and turret:GetPhysicsObject():EnableMotion(false) but those don’t work. The second one (which seems like it should work) gives this error:
Tried to use invalid object (type IPhysicsObject) (Object was NULL or not of the right type)
Sorry if the answer is painfully obvious but I can’t find it.

Have you tried:
turret:SetMoveType(MOVETYPE_NONE)

No I haven’t, I thought it was only for players.

[editline]12:36AM[/editline]

I did that, and it still collides with other turrets and stuff. You can’t move it with the physgun though. Any other ways?

You could try using entity.SetSolid:
turret:SetSolid(SOLID_NONE)

Or use entity.SetCollisionGroup:
turret:SetCollisionGroup(COLLISION_GROUP_NONE)

Neither of those work, npc headcrabs jumping at them still knock them over.

I’ve been working on something similar myself… Can’t get all the bugs out, but perhaps my notes will help you. Each command has 3 or 4 comments after it; what they mean are (in this order): Can it be moved with the Physgun or collisions?, Can the player walk on it correctly?, Does other stuff collide with it?, and lastly, Special notes. Without further ado…

--Ne:PhysicsInit( SOLID_BBOX )		-- bad
--Ne:PhysicsInit( SOLID_NONE )		-- no move, no player, no phys
--Ne:PhysicsInit( SOLID_CUSTOM )	-- can move, bad player, perfect phys
--Ne:PhysicsInit( SOLID_VPHYSICS )	-- can move, bad player, perfect phys
--Ne:PhysicsInit( SOLID_BSP )		-- no move, worst player, perfect phys

--Ne:SetMoveType( MOVETYPE_NONE )	-- no move, no player, no phys, DIVORCES PHYSBOX
--Ne:SetMoveType( MOVETYPE_VPHYSICS )	-- no move, no player, no phys, UNRECOVERABLE

--Ne:SetSolid( SOLID_BBOX )			--no move, no player, no phys
--Ne:SetSolid( SOLID_CUSTOM )		-- no move, no player, no phys, UNRECOVERABLE
--Ne:SetSolid( SOLID_BSP )			-- no move, no player, no phys
--Ne:SetSolid( SOLID_VPHYSICS )		-- can move, perfect player, no phys

Ne:GetPhysicsObject():EnableMotion( false )		-- stops movement until Physgunned

Hope that might help.

While at first it appeared that none of these worked, I finally had the d’oh idea of putting Ent:SetMoveType(MOVETYPE_NONE) AFTER the turret was spawned. This is exactly what I needed. Thanks.