• StartTouch not working ?
    7 replies, posted
Hello, I made an entity and I'm trying to detect collisions with ENT:StartTouch. The problem is that it doesn't detect any collision (I just put a print() inside StartTouch). I looked at an other entity using it (AntiNoClip) but it seems that it doesn't work anymore since the last update... I think the last update broke this hook... any idea ?
Have you tried regular Touch?
Yes, I tried Touch too. But it's the same problem, no collision, no message printed...
Show us your code
Ok here's my code. I took it from the AntiNoClip addon and modified it: init.lua: [lua] AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include( "shared.lua" ) function ENT:SetEnt( ent ) if ( string.Left( ent:GetModel(), 1 ) == "*" ) then return end self.Entity:SetModel( ent:GetModel() ) self.Entity:SetPos( ent:GetPos() ) self.Entity:SetAngles( ent:GetAngles() ) self.Entity:SetParent( ent ) --self.Entity:DrawShadow(false) self.Ent = ent return true end function ENT:Initialize() self.Ent = self.Ent or self:GetParent() if ( !self.Ent || !self.Ent:IsValid() ) then self:Remove() end // Initialise physics. self.Entity:PhysicsInit( SOLID_VPHYSICS ) self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) self.Entity:SetSolid( SOLID_VPHYSICS ) self.Entity:SetTrigger( true ) self.Entity:SetNotSolid( true ) end function ENT:Touch( touched ) -- I tried with ENT:Touch and ENT:StartTouch print("Entity touched") end[/lua] cl_init.lua: [lua]include( "shared.lua" ) function ENT:Draw() end [/lua] shared.lua: [lua] ENT.Type = "anim" ENT.Base = "base_anim" ENT.PrintName = "" ENT.Author = "" ENT.Contact = "" ENT.Spawnable = false ENT.AdminSpawnable = false[/lua] autorun/marmottes.lua: [lua] function FirstSpawn( ply ) ply:ConCommand("play intro.mp3") local an = ents.Create( "mr_antinoclip_handler" ) an:SetEnt( ply ) an:Spawn() ply.AntiNoClip = an an.Owner = ply end hook.Add( "PlayerInitialSpawn", "playerInitialSpawn", FirstSpawn )[/lua] The entity is created when I spawn and follow me (I can see its shadow on the ground)
Parenting an entity disable all collisions with it from every other entity. What are you trying to achieve? [editline]07:59AM[/editline] If what you want to do is disable noclip for that player then use [b][url=wiki.garrysmod.com/?title=Gamemode.PlayerNoClip]Gamemode.PlayerNoClip [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b].
The AntiNoClip addon allow us to add an entity on a prop (the same way as I'm trying to do it here) to catch collisions between that prop and the players. Then the players can't go through the prop. What I'm trying to do, is adding an entity on a player to be able to cache collisions between that entity and the world (to disable noclip with world) The AntiNoClip addon can be found here: [url]http://www.facepunch.com/showthread.php?p=8825605[/url] It was perfectly working before the last update
[QUOTE=Marmotte;22211839] [lua] ENT.Type = "anim" ENT.Base = "base_anim" [/lua] [/QUOTE] Should be brush and base_brush
Sorry, you need to Log In to post a reply to this thread.