Player collide action

How do i set up an entity to activate a function when any player touches it?

StartTouch is when a player moves inside a custom volume (so the entity collides with the brush based entity.) I think he might want **[ENT.Use](** for when you “touch” (hit e) on a custom entity but not sure the question is quite vague.

No, ENT.StartTouch works with Anim entities too.

Didn’t realise that, thanks. :slight_smile:

StartTouch will be called as fast as Touch on anim entities. This is because the engine registers touches with anim entities every frame, unlink StartTouch with a brush which only happens once. You’ll need to do some variable toggling in order to correctly know when the touch has started and stopped.

Sorry if it was a bit vague.

I meant that when i player touches the prop the entity using physically
Would starttouch work for that?


I also don’t understand how i would use it, could someone post a small sample of a better example?

In Anim entities, such as physical props, StartTouch and Touch are the same(as Gbps said). So if you want something to happen only once then this would be what you do:

[lua]function ENT:Touch( entity )

--This checks if the entity touching is a player and if self has been touched before.
if (not entity:IsPlayer() or self.TakeOnce) then return end

--self hasn't been touched, so we set it to true so it can't be touched again.
self.TakeOnce = true

--Do stuff when you touch the entity.


And what would i put as the entity the name of the folder it is in?


Also i am getting an entity error from that code in entity:isplayer

How do i fix it?