Render.drawsphere also draw from inside // When inside run command

So I created a entity with the render.drawsphere how do I make it so it also draws it inside

And my second question, how do I make it so it runs a command or it runs ENT:Use when you enter the sphere

  1. I don’t think there’s a way to get drawsphere to draw on both sides, why do you want that to happen anyway? Is it meant to be a forcefield or something?

  2. A sphere is a pretty simple thing mathematically since it’s the same distance from the center on all sides, so I think all you need to check is the distance the player is from the entity’s origin really -


Just draw a second sphere with a negative size

As for running things;

for k,v in pairs(ents.FindInSphere(spherepos,spheresize) do
     if v:IsPlayer() then
          --do crap

Use a negative value for the radius in render.DrawSphere.

Use this:

render.CullMode and change the cullmode so this draw the inner faces

Naive way to do something when something touches something else, is to hook

GM:Tick on the server, and loop over every sphere, and loop over every player, and check if any players are inside any spheres. This is really bad, and slow.

A better way to do it is to use the same hook, but on the client, to check if they are inside any spheres, and if they are, send a net message to the server. On the server, receive this message and double-check that the player really is inside the sphere. Note that you need to make the sphere “bigger” on the client, since when the client thinks they are inside the sphere and will send the message, is a little earlier then when the server thinks they are in the sphere.