Moving Entity "Zones"

I’m trying to achieve an entity, that when other entities are in the area, are given a variable. Once these entities leave the area, the variable is toggled off. There has to be multiple of these entities. More or less, a moving ‘zone’. The entity has a model and currently runs a loop to find entities in the area, toggles the variable. The think function inside of the variable checks to see if the entity is still inside of the area, if the entity is no longer valid, and other custom variables. It will toggle the variable off if it isn’t(since it moves). The problem here is that I have to use distance checks inside of think hooks, and it just generally feels nasty. I’m curious if there’s a better way to do this. I thought about possibly setting up CollsionBounds for this (in the Entity) for when Entities Enter/Leave but I’m not sure if I can since the entities move and the collision bounds would have to constantly be updated.

Any thoughts or suggestions?

I’m not sure there is, sorry

Have two ent.findInSphere, one slightly larger than your desired area, if the ents are in the smaller area, set your var to true, if it’s in the larger area but not the smaller one, set it to false.

You might have redundancy setting the same variable false every think but it should work, and you won’t be setting the var to false when it’s left the sphere. It just depends on how fast the entity is moving.

[editline]16th June 2013[/editline]

Also, you could use a timed check, say every 5 seconds but you’r var won’t toggle instantly.