GMod Collision Problems

I posted something like this a while back, but now I realize it may not be a lua problem at all, but possibly an engine problem.

Anywho, here’s my console log:



maxplayers set to 8
Unknown command "sv_rollangle"
Unknown command "sv_unlag_fixstuck"
Lua initialized (Lua 5.1)
ERROR! Module 'chattext' not found!
Registering gamemode 'fretta' derived from 'base'
Registering gamemode 'cactus' derived from 'fretta'
ScriptEnforce is disabled
Executing listen server config file
exec: couldn't exec listenserver.cfg

[L] cactus
Map: c_test_01
Players: 1 / 8
Build: 3943
Server Number: 9

No pure server whitelist. sv_pure = 0
Connection to Steam servers successful.
InitFastCopy: only 51% fast props. Bug?
   VAC secure mode is activated.
Lua initialized (Lua 5.1)
ERROR! Module 'chattext' not found!
Registering gamemode 'fretta' derived from 'base'
Registering gamemode 'cactus' derived from 'fretta'
--- Missing Vgui material weapons/cactus
Sending 10 'User Info' ConVars to server (cl_spewuserinfoconvars to see)
Redownloading all lightmaps
Spawning Cacti...
Grea$eMonkey joined Team Catcher
I am HUMEN
I am HUMEN
I am HUMEN
Spawning Cacti...
Max Cacti Reached...


Looks normal right? Well here’s the rundown:

My cactus gamemode has had this problem during development in the past. Basically what happens is at some random time, all SENT’s lose their ability to collide. No errors. I was testing my gamemode moments ago, and collisions worked fine. Then suddenly, all my SENTs stopped colliding.
As you can see, no visible serverside errors.

Now I know what you’re thinking; GM:ShouldCollide() mistake!
Wrong. It has been working for at least a week with no changes to that function whatsoever.
Next on the checklist would be the SENTs themselves. Same basic answer to that too. Those have nothing regarding collisions and have not been changed.

From my observations, it appears to be happening randomly. Until now it has been happening as soon as the game starts, but now I can see that it could happen at any time.

So I’m posing one question: What could possibly be causing this?

Changing collision type while an object is inside another object (ShouldCollide) can cause the physics engine to break. Even if there has been no changes to the function itself, make sure nothing is inside the entities you are colliding when you change their collision.

Instead of using ShouldCollide, try just setting the collision groups of the entities. It’s much less likely to break.

I seem to recall last time I tried changing collision groups, I ended up breaking the engine as well.

I need to make certain entities not-collide with certain others. How else would I do that?

ent:SetCollisionGroup(COLLISION_GROUP_DEBRIS_TRIGGER)

Collides with the world, doesn’t collide with players. (I think) or other debris. Needs run on server and client.

Can’t we create our own collision groups?

I’m not sure. I’ve never looked into creating a collision group.

I don’t think the built in groups are going to help me.

It’s very possible collision group can be calculated using bitwise too. Try that - look at the collision group enumerations to see if it’s possible or not. I can’t right now, got too much stuff to do right now.

I have no idea what you mean.

Unfortunately, it’s looking like it wouldn’t work. Look into it though.

Here’s what I have.

[lua]
function GM:ShouldCollide(Ent1, Ent2)

self.BaseClass:ShouldCollide(Ent1, Ent2)
--cactus player vs cactus ent = false
--grabber vs world or player = false
--player vs player = false
if Ent1:IsPlayer() then
	if Ent1:IsCactus() and Ent2:IsCactus() then
		return false
	end
	if Ent2:IsPlayer() then
		return false
	end
elseif Ent1:GetClass() == "grabber" then
	if Ent2:IsPlayer() or Ent2:GetClass() == "worldspawn" then
		return false
	end
end

return true

end
[/lua]

How else will I do this?

No, Collision groups don’t work like that…


COLLISION_GROUP_NONE	=	0
COLLISION_GROUP_DEBRIS	=	1
COLLISION_GROUP_DEBRIS_TRIGGER	=	2
COLLISION_GROUP_INTERACTIVE_DEBRIS	=	3
COLLISION_GROUP_INTERACTIVE	=	4
COLLISION_GROUP_PLAYER	=	5
COLLISION_GROUP_BREAKABLE_GLASS	=	6
COLLISION_GROUP_VEHICLE	=	7
COLLISION_GROUP_PLAYER_MOVEMENT	=	8
COLLISION_GROUP_NPC	=	9
COLLISION_GROUP_IN_VEHICLE	=	10
COLLISION_GROUP_WEAPON	=	11
COLLISION_GROUP_VEHICLE_CLIP	=	12
COLLISION_GROUP_PROJECTILE	=	13
COLLISION_GROUP_DOOR_BLOCKER	=	14
COLLISION_GROUP_PASSABLE_DOOR	=	15
COLLISION_GROUP_DISSOLVING	=	16
COLLISION_GROUP_NPC_ACTOR	=	18
COLLISION_GROUP_PUSHAWAY	=	17
COLLISION_GROUP_NPC_SCRIPTED	=	19
COLLISION_GROUP_WORLD	=	20

As proven by [this](http://www.google.com/codesearch/p?hl=en#Gzw6-f1bgME/trunk/codebases/from-source/game_shared/gamerules.cpp&q=COLLISION_GROUP_DEBRIS package:http://modderation.googlecode.com&sa=N&cd=10&ct=rc&l=578)

I realised when I looked up the enumerations. Anyway, I haven’t noticed anything for making your own collision group.