Disabling collisions completely on a lua trigger entity
14 replies, posted
Hi, I've made a brush trigger entity in lua that will when first touched, update the players zone. Currently, it works perflectly well, as it seems invisble to the player. All ents inside the zones seem to have no issues. However, other entities still pickup my trigger entity with the Touch, StartTouch and EndTouch hook.
if SERVER then
ENT.Base = "base_brush"
ENT.Type = "brush"
ENT.Zone = 1
ENT.IsZoneTrigger = true
-- Updates the bounds of this collision box
function ENT:SetBounds(min, max)
self:SetSolid(SOLID_BBOX)
self:SetCollisionGroup(COLLISION_IN_VEHICLE) -- i have also tested COLLISION_GROUP_WORLD
self:SetCollisionBoundsWS(min, max)
self:SetTrigger(true)
end
-- Run when any entity starts touching our trigger
function ENT:StartTouch(ply)
if ply:IsPlayer() then
ply.impulseZone = self.Zone
end
end
function ENT:UpdateTransmitState()
return TRANSMIT_NEVER
end
end
Is there any way I can completely disable other entities physically detecting this entity while maintaining its purpose as a trigger for player?
Thanks.
check if the entity is a player?
That may well work but I try to steer well clear of that hook due to its relation to instability and crashes.
Touch shouldn't result in any crashes at all. I am using a zone system based on brushes too and I never had a single crash. It could cause a crash if you do something actual physics related in it.
I was reffering to GM/ShouldCollide.
Oh, sry, missed that. Well, I don't know why this function would cause crashes either. Maybe it depends on how you use it and what you actually do in it.
ShouldCollide is fine as long as you don't do any kind of physics manipulation in it? Read the console error message
I just found out that brushes (can) use filters.
Great find, I'll experiment with this now.
Just tested that, it's a broken hook. I also took a look at the wiki's workaround however that won't actually solve the problems of other entities detecting it via the Touch functions. I also had a look at SetSolidFlags with FSOLID_NOT_SOLID and FSOLID_TRIGGER and they did not work either. It would be great if there was a function we could call called that could enabled/disable external collisions.
I implemented trigger_once, trigger_multiple and family just fine in Lua. You can find the code here: Lambda/lambda_trigger.lua at develop · ZehMatt/Lambda · GitHub
Thanks, did your triggers activate the Touch hooks of other entities if so, how did you disable it? I tried implementing bits from your triggers into mine but I can't seem to find how you stopped that from happening.
I never quite ran into this kind of situation given that I only target vanilla functionality. The ShouldCollide hook only deals with blocked triggers in my case so NPC's can still pass thru while players can not.
From what I understand is you want to disable Touch/StartTouch events on your entities when they enter the trigger, this seems to be the normal behavior in Source.
Hey, thanks for the help. Seems like I can't really solve it but hopefully most addons with ents will use PhysicsCollide instead of the Touch functions.
Out of curiosity, have you tried if the same happens on vanilla trigger_once/trigger_multiple?
Sorry, you need to Log In to post a reply to this thread.