Correcting Clientside Prediction Issues When Colliding With Custom Physics Meshes

Good Morning,

I’m currently working on a widget to shrink all props globally. However, it seems that with my current method when I stand on a props edges it kind of sticks/glitches and I fall through the prop. If I have a large flat prop like a PHX plate I can stand on its center with nothing major to report, however if I move near its edges my player sort of “slips” and then falls through the prop.

My code thus far is as follows:



function GM:PlayerSpawnedProp( ply, model, ent )
		--First we shrink the prop on the server
		--So to start off, initialize normal physics so we can get our mesh vertices
		ent:PhysicsInit( SOLID_VPHYSICS )
		ent:SetMoveType( MOVETYPE_VPHYSICS )

		--Next, we store a local variable filled with the initial vertices
		local phys	= ent:GetPhysicsObject()
		local convexes	= phys:GetMeshConvexes()
		local mass 	= phys:GetMass()	

		--Begin the clipping procedures, GetMeshConvexes returns vertices' coordinates as local vectors in relation
		--to the model origin, therefore we need to simply multiply each individual convex's local vector by a scalar

		local miniconvexes = {}
		for i, convex in ipairs( convexes ) do
			miniconvexes* = {}
			for j, vertex in ipairs( convex ) do
				miniconvexes*[j] = vertex.pos * (1/2)
			end
		end

		--Then we reinitialize our new clipped physics

		ent:PhysicsInitMultiConvex( miniconvexes )

		--Then we enable custom collisions, unsure if it is actually as self explanatory as it seems
		ent:EnableCustomCollisions( true ) 
		ent:SetCustomCollisionCheck( true )
		ent:SetModelScale( ent:GetModelScale() * (1/2), 0 )
		ent:GetPhysicsObject():SetMass( mass )
end



Anyone know any other commands or physics modifications I can do? This function is contained within shared.lua, so its running on both the client and the server and therefore they should have equitable physics objects.

I’m just trying to avoid having to replace all the shrunk entities with scripted entities. :c

You gotta init the physics on client too, and then fix all the stuff that breaks if you do so.
MDave know how to do this, so you can contact him or something.

It’s in shared so it should be performing identically to the server.

MDave doesn’t really initialize client-side physics, he makes a scripted entity which mirrors the proper position for clients.

He really does, the client can’t know the physics model of your object otherwise, means prediction is impossible.