Entity StartTouch not detected

Hey,

I have two entities. Both Entities have the self:SetTrigger( true ) set in the Initialize function. Both Entities spawn perfectly However when I touch both entities together it does not detect it. I’m stumped to why this would occur. The entity will detect me standing on it, props ect. Just not the other entity.
Entity1:



function ENT:Initialize()
self:SetModel("models/props_c17/furnituresink001a.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
    self:SetTrigger( true )
        local phys = self:GetPhysicsObject()
    if (phys:IsValid()) then
        phys:Wake()
    end

function ENT:StartTouch(ent)
	print("We were touched by" .. ent:GetClass())
        print(ent:GetModel())
end


Entity2:



function ENT:Initialize()
    self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_BBOX )
	self:SetUseType( SIMPLE_USE )
	self:SetTrigger( true )
	self:SetModel("models/props_interiors/Furniture_chair03a.mdl")
	local phys = self:GetPhysicsObject()
	if phys:IsValid() then
		phys:EnableCollisions(true)
		phys:Wake()
	end
end


Try adding this to the top of the file if you haven’t already:



ENT.Type = "anim"


Both have
ENT.Type = “anim”
ENT.Base = “base_gmodentity”

Your second entity uses



self:SetSolid( SOLID_BBOX )


Maybe try changing that to



self:SetSolid( SOLID_VPHYSICS )


[editline]10th October 2017[/editline]

Also, I think you need to set the model before intializing the physics

Also quick reminder to set the physics and initiate them serverside, I spent hours figuring out why the physgun didn’t follow the prop when moving it only to realize I ran the code clientside too.

Tried everything you said still no :s:. Also this is all server side for physics

If entity 1 touches itself, does it print anything? Same for entity 2?

It might be a problem lurking somewhere in only one of the entity’s files.

Try setting the model before setting the physics, that’s what I always do. If you want to set the model AFTER setting the physics then you will need to make your own hitbox with SetCollisionBound

edit: Even when I make my own hitbox I always set the model first
edit2: Oops I see it was already said

Okay so Entity1 can touch it self but entity 2 cant touch itself. BUT can be touched if I stand on it

Entity2 Serverside:



AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" )

function ENT:Initialize()

	self:SetModel("models/props_interiors/Furniture_chair03a.mdl")
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_VPHYSICS  )
	self:SetUseType( SIMPLE_USE )
	self:SetTrigger( true )
	local phys = self:GetPhysicsObject()
	if phys:IsValid() then
		phys:EnableCollisions(true)
		phys:Wake()
	end


end


function ENT:StartTouch(ent)
	print("We were touched by some" .. ent:GetClass())
end


Try this http://wiki.garrysmod.com/page/Entity/SetCollisionGroup

Tried setting the group to COLLISION_GROUP_NONE and COLLISION_GROUP_INTERACTIVE.
No luck

The only difference I can see between entity 1 and 2 is this line:



phys:EnableCollisions(true)


I don’t know why that’d make a difference, but maybe commenting it out might do something?
Also,

Entity:PhysWake can remove a few lines of code

Fixed!

Some reason putting self:SetTrigger( true ) under the setmodel before setting PhysicsInit seems to have solved it.

Thank you everyone