Facepunch / garrysmod-requests

Feature requests for Garry's Mod
83 stars 24 forks source link

Entity:SetPreventTransmit, No Collide PhysObj #274

Closed 8BallBomBom closed 10 years ago

8BallBomBom commented 10 years ago

I don't know if this function was originally intended to make the PhysObj remain for players that have been told not to receive the entity but would it be possible to make it hide or no collide the PhysObj with players that are told not to receive the entity?

I could do this myself using the custom collision hook but generally it would be a lot nicer if you could just toggle entities from being transmitted and that would also mean the PhysObj would no longer collide with players that are told not to receive the entity.

Otherwise any other decent solutions?

UnderscoreKilburn commented 10 years ago

This would be like making Entity:SetNoDraw implicitly turn the entity non-solid as well. Just because you can't see something doesn't mean it doesn't exist.

A custom collision hook is the right way to do it.

8BallBomBom commented 10 years ago

Makes sense kinda but then is there really any point having the function if it pretty much does the same as SetNoDraw?

Typically you'd expect if the server is the thing making the object visible and sending the physical object properties over then this kind of function would totally prevent it being present on the client.

I plan on making a kind of dimension/layers system for sandbox, if this function just prevented the entity from existing on select clients then that sort of system would be easily possible.

I can use the custom collision check, just hope the performance doesn't degrade or the physics breaks. Also if you tell an Entity to use the custom collision check but then tell it not to use the custom collision check, it still uses the custom collision check.

UnderscoreKilburn commented 10 years ago

It's not the same thing as SetNoDraw as all. An example use case would be cloaked spies in TF2, you don't want them to be visible to players on the opposite team. You could do that by not drawing them clientside if they don't belong to the same team as the local player, but that would be unreliable and clients would be able to cheat around that. The best solution would be to prevent the server from sending their position to enemy players, and that's where you would use SetPreventTransmit. The only thing this function does it control visibility, it has nothing to do with collisions.

As for the custom collision check, if what you're saying is true then it's an issue and you should report it in the issues repository so I can remember to take a look at it later.

8BallBomBom commented 10 years ago

Will do and totally thought it was just for visibility. Didn't even expect it to just remove position sending.

With a function name like that you'd typically expect it to totally cut off sending everything in relation to the Entity which surely if the physics object is on the server, if it wasn't also on the client then the same effect as no collision would be created?

UnderscoreKilburn commented 10 years ago

I see where you're going, in practice the physics object doesn't get transmitted either so it effectively stops existing on the client, which causes a conflict with the server if you try to run into it, causing you to seemingly bounce off an invisible forcefield. So in this case why not just disable collisions as well to prevent this from happening?

Well the answer is simple: you can easily do it yourself. It's a behaviour that isn't expected from this function and might even be undesirable in some cases since it also adds a performance overhead.

8BallBomBom commented 10 years ago

Understandable, thanks for the heads up.