I'm trying to attach a Enitityto another Enitity,
but the attached Enitity has no Collision...
[CODE]
function ENT:Touch( ent )
if ( ent:IsPlayer() ) then return end
if ( ent:GetClass() == "monitor" && !self:GetConnected() ) then
local ent2 = ents.Create("monitor")
ent2:SetParent(self,1)
self:SetConnected(true)
ent2:SetConnected(true)
ent2:SetMoveType( MOVETYPE_VPHYSICS )
ent2:SetPos( self:LocalToWorld(ent2:GetPos() + Vector(0,25,0)) )
ent2:SetAngles( self:GetAngles() )
ent2:Spawn()
ent:Remove()
end
end
[/CODE]
What does SetConnected do? Also, you seem to be spawning a new monitor when you may just be able to use the old one
I have 2 Entities,
monitor and computer
SetConnected & GetConnected checks if theres already a Monitor connected to the Computer...
My problem is, the attached Entity clipps through the ground and the Base Entity not.
New Code that I made...
init.lua - monitor Enitity
[CODE]
function ENT:Touch( ent )
if ( ent:IsPlayer() ) then return end
if ( ent:GetClass() == "computer" && !self:GetConnected() && !ent:GetConnected() ) then
self:SetConnected(true)
ent:SetConnected(true)
local pos, ang = LocalToWorld( Vector(0,25,0), Angle(0,0,0), ent:GetPos(), ent:GetAngles() )
self:SetPos( pos )
self:SetParent( ent, -1 )
self:SetAngles( ang )
self:SetMoveType( MOVETYPE_VPHYSICS )
end
end
[/CODE]
ent:GetPhysicsObject():EnableCollisions( true )
try this, I really don't know how this works as I never used this before but I hope it will work?
Going to try it
[B]Edit:[/B]
Thanks! Works!
[CODE]
function ENT:StartTouch( ent )
if ( ent:IsPlayer() ) then return end
if ( ent:GetClass() == "computer" && !self:GetConnected() && !ent:GetConnected() ) then
self:SetConnected(true)
ent:SetConnected(true)
local pos, ang = LocalToWorld( Vector(0,25,0), Angle(0,0,0), ent:GetPos(), ent:GetAngles() )
self:SetPos( pos )
self:SetParent( ent )
self:SetAngles( ang )
self:GetPhysicsObject():EnableCollisions( true )
end
end
[/CODE]
Sorry, you need to Log In to post a reply to this thread.