• How to make an entity collide with NPC/player hitboxes, not bounding box?
    25 replies, posted
Is there a solid flag for that or something? SOLID_NONE collides only with world, but doesn't call ENT:Touch(), others collide with anything including bounding boxes. Next, FSOLID_MAX_BITS without setting SetSolid collides with world and world entities, calling ENT:Touch(). And for NPCs, prop_physics, players I must do a trace check in Think hook. This is kinda silly. How to set everything properly, so it hits everything BUT bounding boxes for NPCs? Also, I don't use physics.
Just wondering if you're aware of the wiki warnings for ENT:Touch() https://i.imgur.com/fJEWQfo.png
Ah, indeed. Any other methods without setting physics object?
I think you should be good if you have SetTrigger set to true, try it and let me know.
Nope. Collides only with world and world entities
I'm a bit confused, you want to collide with everything except for NPCs?
With everything including NPCs. But by default it collides with their bounding box instead of model hitboxes
I could be wrong here but I think you need to enable physics and SetSolid to SOLID_VPHYSICS
Even with physics it collides with bounding boxes [code] function ENT:Initialize()     self:SetSolid(SOLID_VPHYSICS)     self:SetModel(self.Model)     self:PhysicsInitBox(Vector(), Vector()) local phys = self:GetPhysicsObject() if IsValid(phys) then phys:EnableGravity(false) phys:SetVelocity(self:GetForward() * 2000) end end function ENT:StartTouch(ent)     print(ent) -- calls on bounding box hit end [/code]
I think you need to use this for physics collisions
Yes, but the entity still hits bounding boxes. No matter where we detect collisions.
You don't wanna be calling PhysicsInitBox even with a nil Vector https://files.facepunch.com/forum/upload/113051/ae42d326-ce47-42e9-8de1-249f14fbb4b8/image.png
Then there won't be physics object. My model doesn't have physics mesh
Have you considered using a bounding box but editing the Hull?
Do you mean SOLID_BBOX with self:SetCollisionBounds()? I don't get it
Yes SetCollisionBounds would work for when you're using SOLID_BBOX. This may be of use: NPC/SetHullType
No matter what I do, the entity always hits a bounding box. I guess, the only solution is checking hit in Think with traces. Damn. https://puu.sh/A1zq9/65e548258c.webm
I think the real issue is the lack of a physics mesh
Just tried another model with physics mesh. Same result.
May I see the code?
function ENT:Initialize()     self:SetModel("models/props_lab/cactus.mdl")     self:PhysicsInit( SOLID_VPHYSICS ) local phys = self:GetPhysicsObject()     if IsValid(phys) then         phys:Wake()         phys:EnableGravity(false)         phys:SetVelocity(self:GetForward() * 100)     end end This is enough for tests. Am I missing something?
you better use some traces
[code] AddCSLuaFile() ENT.Base      = "base_ai" ENT.Spawnable   = true function ENT:Initialize()     self:SetModel( "models/alyx.mdl" )   self:PhysicsInit( SOLID_VPHYSICS )      -- Make us work with physics,   self:SetMoveType( MOVETYPE_VPHYSICS )   -- after all, gmod is a physics   self:SetSolid( SOLID_VPHYSICS )         -- Toolbox     local phys = self:GetPhysicsObject()   if (phys:IsValid()) then     phys:Wake()   end end [/code] Try this, pretty sure the issue was the lack of a base.
Well, seems like there's nothing we can do here. I'll continue using traces in Think Thanks for your help.
Hitboxes cannot be used for collision by default; it would be extremely expensive since you're tracing rotated boxes against other rotated boxes.
So if I do traces every tick, how bad is it?
Sorry, you need to Log In to post a reply to this thread.